/
extract-fingerprint-config.spec.ts
118 lines (114 loc) · 3.64 KB
/
extract-fingerprint-config.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import { mergeChildConfig } from '../../../config';
import { getConfig } from '../../../config/defaults';
import { getManagerList } from '../../../modules/manager';
import { generateFingerprintConfig } from './extract-fingerprint-config';
describe('workers/repository/extract/extract-fingerprint-config', () => {
it('filter with enabledManagers', () => {
const config = mergeChildConfig(getConfig(), {
registryAliases: {
stable: 'http://some.link', // intentionally placing the field incorrectly
},
ignorePaths: ['ignore-path-1'],
includePaths: ['include-path-1'],
npm: {
fileMatch: ['hero.json'],
ignorePaths: ['ignore-path-2'],
includePaths: ['include-path-2'],
registryAliases: {
notStable: 'http://some.link.2',
},
},
enabledManagers: ['npm', 'regex'],
regexManagers: [
{
fileMatch: ['js', '***$}{]]['],
matchStrings: ['^(?<depName>foo)(?<currentValue>bar)$'],
datasourceTemplate: 'maven',
versioningTemplate: 'gradle',
},
],
});
const fingerprintConfig = generateFingerprintConfig(config);
expect(fingerprintConfig.managerList).toEqual(new Set(['npm', 'regex']));
expect(
fingerprintConfig.managers.find((manager) => manager.manager === 'npm')
).toEqual({
enabled: true,
fileList: [],
fileMatch: ['(^|/)package\\.json$', 'hero.json'],
ignorePaths: ['ignore-path-2'],
includePaths: ['include-path-2'],
manager: 'npm',
npmrc: null,
npmrcMerge: false,
registryAliases: {
notStable: 'http://some.link.2',
},
skipInstalls: null,
});
expect(
fingerprintConfig.managers.find((manager) => manager.manager === 'regex')
).toEqual({
fileMatch: ['js', '***$}{]]['],
ignorePaths: ['ignore-path-1'],
includePaths: ['include-path-1'],
fileList: [],
matchStrings: ['^(?<depName>foo)(?<currentValue>bar)$'],
datasourceTemplate: 'maven',
versioningTemplate: 'gradle',
enabled: true,
manager: 'regex',
npmrc: null,
npmrcMerge: false,
registryAliases: {
stable: 'http://some.link',
},
skipInstalls: null,
});
});
it('filter with all managers enabled', () => {
const config = mergeChildConfig(getConfig(), {
npmrc: 'some-string',
npmrcMerge: true,
npm: { fileMatch: ['hero.json'] },
});
const fingerprintConfig = generateFingerprintConfig(config);
expect(fingerprintConfig.managerList).toEqual(new Set(getManagerList()));
expect(
fingerprintConfig.managers.find((manager) => manager.manager === 'npm')
).toEqual({
enabled: true,
fileList: [],
fileMatch: ['(^|/)package\\.json$', 'hero.json'],
ignorePaths: ['**/node_modules/**', '**/bower_components/**'],
includePaths: [],
manager: 'npm',
npmrc: 'some-string',
npmrcMerge: true,
registryAliases: {},
skipInstalls: null,
});
expect(
fingerprintConfig.managers.find(
(manager) => manager.manager === 'dockerfile'
)
).toEqual({
enabled: true,
fileList: [],
fileMatch: [
'(^|/|\\.)([Dd]ocker|[Cc]ontainer)file$',
'(^|/)([Dd]ocker|[Cc]ontainer)file[^/]*$',
],
ignorePaths: ['**/node_modules/**', '**/bower_components/**'],
includePaths: [],
manager: 'dockerfile',
npmrc: 'some-string',
npmrcMerge: true,
registryAliases: {},
skipInstalls: null,
});
expect(
fingerprintConfig.managers.find((manager) => manager.manager === 'regex')
).toBeUndefined();
});
});