-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.test.js
96 lines (79 loc) · 2.2 KB
/
index.test.js
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
/* eslint-disable global-require */
describe('schemas', () => {
describe('amazon schema', () => {
test('normal case', () => {
const { amazonSchema } = require('./index')
const input = {
amazon: {
aws_access_key_id: 'xx',
aws_secret_access_key: 'xx',
aws_region: 'xx',
},
}
const { error } = amazonSchema.validate(input)
expect(error).not.toBeDefined()
})
test('allows aws_session_token field', () => {
const { amazonSchema } = require('./index')
const input = {
amazon: {
aws_access_key_id: 'xx',
aws_secret_access_key: 'xx',
aws_region: 'xx',
aws_session_token: 'xx',
},
}
const { error } = amazonSchema.validate(input)
expect(error).not.toBeDefined()
})
test('does not allow missing field in amazon', () => {
const { amazonSchema } = require('./index')
const input = {
amazon: {
aws_access_key_id: 'xx',
aws_secret_access_key: 'xx',
// Missing: aws_region: '',
},
}
const { error } = amazonSchema.validate(input)
expect(error).toBeDefined()
})
test('does not allow both providers', () => {
const { amazonSchema } = require('./index')
const input = {
amazon: {
aws_access_key_id: 'abc',
aws_secret_access_key: 'abc',
aws_region: 'abc',
},
google: {
gc_project: 'abc',
gc_region: 'abc',
},
}
const { error } = amazonSchema.validate(input)
expect(error).toBeDefined()
})
test('does not allow no provider', () => {
const { amazonSchema } = require('./index')
const input = {
// empty
}
const { error } = amazonSchema.validate(input)
expect(error).toBeDefined()
})
})
describe('google schema', () => {
test('normal case', () => {
const { googleSchema } = require('./index')
const input = {
google: {
gc_project: 'abc',
gc_region: 'abc',
},
}
const { error } = googleSchema.validate(input)
expect(error).not.toBeDefined()
})
})
})