forked from renovatebot/renovate
/
extract.spec.ts
58 lines (54 loc) · 1.75 KB
/
extract.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import fs from 'fs';
import { extractPackageFile } from './extract';
const yamlFile = fs.readFileSync(
'lib/manager/gitlabci-include/__fixtures__/gitlab-ci.1.yaml',
'utf8'
);
const yamlLocal = fs.readFileSync(
'lib/manager/gitlabci-include/__fixtures__/gitlab-ci.2.yaml',
'utf8'
);
const yamlLocalBlock = fs.readFileSync(
'lib/manager/gitlabci-include/__fixtures__/gitlab-ci.3.yaml',
'utf8'
);
describe('lib/manager/gitlabci-include/extract', () => {
describe('extractPackageFile()', () => {
it('returns null for empty', async () => {
expect(
await extractPackageFile('nothing here', '.gitlab-ci.yml', {})
).toBeNull();
});
it('extracts multiple include blocks', async () => {
const res = await extractPackageFile(yamlFile, '.gitlab-ci.yml', {});
expect(res.deps).toMatchSnapshot();
expect(res.deps).toHaveLength(3);
});
it('extracts local include block', async () => {
const res = await extractPackageFile(yamlLocal, '.gitlab-ci.yml', {});
expect(res.deps).toMatchSnapshot();
expect(res.deps).toHaveLength(1);
});
it('extracts multiple local include blocks', async () => {
const res = await extractPackageFile(
yamlLocalBlock,
'.gitlab-ci.yml',
{}
);
expect(res.deps).toMatchSnapshot();
expect(res.deps).toHaveLength(2);
});
it('normalizes configured endpoints', async () => {
const endpoints = [
'http://gitlab.test/api/v4',
'http://gitlab.test/api/v4/',
];
for (const endpoint of endpoints) {
const res = await extractPackageFile(yamlFile, '.gitlab-ci.yml', {
endpoint,
});
expect(res.deps[0].registryUrls[0]).toEqual('http://gitlab.test');
}
});
});
});