-
Notifications
You must be signed in to change notification settings - Fork 2
/
main_test.go
34 lines (28 loc) · 869 Bytes
/
main_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
package main
import (
"github.com/cosmonawt/vaulter-white/conf"
"github.com/cosmonawt/vaulter-white/vault"
"github.com/stretchr/testify/assert"
"os"
"testing"
)
func TestPrepareEnvironment(t *testing.T) {
config := conf.Config{
SecretPaths: map[string]map[string]string{
"testSecret1": {
"testKey1": "TEST_VAL1",
},
},
}
secrets := map[string]vault.SecretData{
"testSecret1": {
"testKey1": "TestValue1",
"testKey2": "TestValue2",
},
}
os.Setenv("TESTENV", "TESTVAL")
testEnv := PrepareEnvironment(secrets, config)
assert.Contains(t, testEnv, "TEST_VAL1=TestValue1", "Secrets should be saved according to config")
assert.Contains(t, testEnv, "TESTSECRET1_TESTKEY2=TestValue2", "Secrets should be saved if config is absent")
assert.Contains(t, testEnv, "TESTENV=TESTVAL", "Existing environment variables should be included")
}