forked from renovatebot/renovate
/
host-rules-migration.spec.ts
77 lines (75 loc) · 2.17 KB
/
host-rules-migration.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
import { CONFIG_VALIDATION } from '../../../constants/error-messages';
import { HostRulesMigration } from './host-rules-migration';
describe('config/migrations/custom/host-rules-migration', () => {
it('should migrate array', () => {
expect(HostRulesMigration).toMigrate(
{
hostRules: [
{
hostType: 'dotnet',
baseUrl: 'https://some.domain.com',
token: '123test',
},
{
hostType: 'adoptium-java',
domainName: 'domain.com',
token: '123test',
},
{ domainName: 'domain.com/', token: '123test' },
{ hostType: 'docker', matchHost: 'domain.com/', token: '123test' },
{ hostName: 'some.domain.com', token: '123test' },
{ endpoint: 'domain.com/', token: '123test' },
{ host: 'some.domain.com', token: '123test' },
],
} as any,
{
hostRules: [
{
hostType: 'dotnet-version',
matchHost: 'https://some.domain.com',
token: '123test',
},
{
hostType: 'java-version',
matchHost: 'domain.com',
token: '123test',
},
{
matchHost: 'https://domain.com/',
token: '123test',
},
{
hostType: 'docker',
matchHost: 'https://domain.com/',
token: '123test',
},
{ matchHost: 'some.domain.com', token: '123test' },
{ matchHost: 'https://domain.com/', token: '123test' },
{ matchHost: 'some.domain.com', token: '123test' },
],
}
);
});
it('throws when multiple hosts are present', () => {
expect(() =>
new HostRulesMigration(
{
hostRules: [
{
matchHost: 'https://some.domain.com',
baseUrl: 'https://some.domain.com',
token: '123test',
},
],
} as any,
{}
).run([
{
matchHost: 'https://some.domain.com',
baseUrl: 'https://some.domain.com',
token: '123test',
},
])
).toThrow(CONFIG_VALIDATION);
});
});