-
Notifications
You must be signed in to change notification settings - Fork 2
/
config_test.go
91 lines (72 loc) · 1.84 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestConfig_ConsulPaths(t *testing.T) {
t.Parallel()
t.Run("full config", func(t *testing.T) {
t.Parallel()
c := Config{Service: "foo", Environment: "stage"}
assert.Equal(t, []string{
"global/env_vars",
"global/stage/env_vars",
"services/foo/env_vars",
"services/foo/stage/env_vars",
}, c.ConsulPaths())
})
t.Run("no service", func(t *testing.T) {
t.Parallel()
c := Config{Environment: "stage"}
assert.Equal(t, []string{
"global/env_vars",
"global/stage/env_vars",
}, c.ConsulPaths())
})
}
func TestConfig_VaultPaths(t *testing.T) {
t.Parallel()
t.Run("stage", func(t *testing.T) {
t.Parallel()
c := Config{Service: "foo", Environment: "stage"}
assert.Equal(t, []string{
"secret/global/env_vars",
"secret/global/stage/env_vars",
"secret/services/foo/env_vars",
"secret/services/foo/stage/env_vars",
}, c.VaultPaths())
})
t.Run("prod", func(t *testing.T) {
t.Parallel()
c := Config{Service: "foo", Environment: "prod"}
assert.Equal(t, []string{
"secret/global/env_vars",
"secret/global/prod/env_vars",
"secret/services/foo/env_vars",
"secret/services/foo/prod/env_vars",
}, c.VaultPaths())
})
t.Run("dev", func(t *testing.T) {
t.Parallel()
c := Config{Service: "foo", Environment: "dev"}
assert.Equal(t, []string{
"secret/global/dev/env_vars",
"secret/services/foo/dev/env_vars",
}, c.VaultPaths())
})
t.Run("no service", func(t *testing.T) {
t.Parallel()
c := Config{Environment: "prod"}
assert.Equal(t, []string{
"secret/global/env_vars",
"secret/global/prod/env_vars",
}, c.VaultPaths())
})
t.Run("no service dev", func(t *testing.T) {
t.Parallel()
c := Config{Environment: "dev"}
assert.Equal(t, []string{
"secret/global/dev/env_vars",
}, c.VaultPaths())
})
}