forked from fluxcd/flux-recv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_test.go
67 lines (59 loc) · 1.18 KB
/
config_test.go
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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
const missingVersion = `
# missing fluxRecvVersion
# all else well
api: http://localhost:3034/fluxapi
endpoints:
- keyPath: ./foo_rsa
- source: DockerHub
`
const completelyDifferentFile = `
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello
spec:
template:
spec:
containers:
- name: hello
image: helloworld
`
func TestBadConfigs(t *testing.T) {
for name, testcase := range map[string]string{
"missing version": missingVersion,
"wrong kind of file": completelyDifferentFile,
} {
t.Run(name, func(t *testing.T) {
_, err := ConfigFromBytes([]byte(testcase))
assert.Error(t, err)
})
}
}
const fullConfig = `
fluxRecvVersion: 1
api: http://localhost:3031/api/flux
endpoints:
- source: GitHub
keyPath: ./github_rsa
- source: DockerHub
keyPath: ./dockerhub_rsa
`
const minimalConfig = `
fluxRecvVersion: 1
`
func TestGoodConfigs(t *testing.T) {
for name, testcase := range map[string]string{
"minimal": minimalConfig,
"full config": fullConfig,
} {
t.Run(name, func(t *testing.T) {
_, err := ConfigFromBytes([]byte(testcase))
assert.NoError(t, err)
})
}
}