8
8
"os/exec"
9
9
"path/filepath"
10
10
"strconv"
11
- "strings"
12
11
"testing"
13
12
"time"
14
13
@@ -42,14 +41,15 @@ func TestFormatForEnvString(t *testing.T) {
42
41
Path : "mysql1/password" ,
43
42
Tags : []secretsyml.YamlTag {secretsyml .Var },
44
43
}
45
- envvar := formatForEnv (
44
+ k , v := formatForEnv (
46
45
"dbpass" ,
47
46
"mysecretvalue" ,
48
47
spec ,
49
48
nil ,
50
49
)
51
50
52
- So (envvar , ShouldEqual , "dbpass=mysecretvalue" )
51
+ So (k , ShouldEqual , "dbpass" )
52
+ So (v , ShouldEqual , "mysecretvalue" )
53
53
})
54
54
Convey ("For files, VALUE should be the path to a tempfile containing the secret" , func () {
55
55
tempFactory := NewTempFactory ("" )
@@ -59,16 +59,13 @@ func TestFormatForEnvString(t *testing.T) {
59
59
Path : "certs/webtier1/private-cert" ,
60
60
Tags : []secretsyml.YamlTag {secretsyml .File },
61
61
}
62
- envvar := formatForEnv (
62
+ key , path := formatForEnv (
63
63
"SSL_CERT" ,
64
64
"mysecretvalue" ,
65
65
spec ,
66
66
& tempFactory ,
67
67
)
68
68
69
- s := strings .Split (envvar , "=" )
70
- key , path := s [0 ], s [1 ]
71
-
72
69
So (key , ShouldEqual , "SSL_CERT" )
73
70
74
71
// Temp path should exist
@@ -84,8 +81,8 @@ func TestFormatForEnvString(t *testing.T) {
84
81
85
82
func TestJoinEnv (t * testing.T ) {
86
83
Convey ("adds a trailing newline" , t , func () {
87
- result := joinEnv ([ ]string {"foo" , "bar" })
88
- So (result , ShouldEqual , "foo\n bar \n " )
84
+ result := joinEnv (map [ string ]string {"foo" : "bar" , "baz" : "qux " })
85
+ So (result , ShouldEqual , "foo= \" bar \" \n baz= \" qux \" \n " )
89
86
})
90
87
}
91
88
0 commit comments