forked from tellerops/teller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers_test.go
39 lines (31 loc) · 1.04 KB
/
helpers_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
package providers
import (
"testing"
"github.com/alecthomas/assert"
"github.com/spectralops/teller/pkg/core"
"github.com/spectralops/teller/pkg/logging"
)
func AssertProvider(t *testing.T, s core.Provider, sync bool) {
p := core.NewPopulate(map[string]string{"stage": "prod"})
kpmap := p.KeyPath(core.KeyPath{Field: "MG_KEY", Path: "settings/{{stage}}/billing-svc/all", Decrypt: true})
kp := p.KeyPath(core.KeyPath{Field: "MG_KEY", Path: "settings/{{stage}}/billing-svc", Decrypt: true})
kpenv := p.KeyPath(core.KeyPath{Env: "MG_KEY", Path: "settings/{{stage}}/billing-svc", Decrypt: true})
ent, err := s.Get(kp)
assert.Nil(t, err)
assert.Equal(t, ent.Value, "shazam")
ent, err = s.Get(kpenv)
assert.Nil(t, err)
assert.Equal(t, ent.Value, "shazam")
if sync {
ents, err := s.GetMapping(kpmap)
assert.Nil(t, err)
assert.Equal(t, len(ents), 2)
assert.Equal(t, ents[0].Value, "mailman")
assert.Equal(t, ents[1].Value, "shazam")
}
}
func GetTestLogger() logging.Logger {
logger := logging.New()
logger.SetLevel("null")
return logger
}