Skip to content

Commit 543bc48

Browse files
committed
Fix unit tests
1 parent ea7824b commit 543bc48

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

internal/command/action_test.go

+6-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"os/exec"
99
"path/filepath"
1010
"strconv"
11-
"strings"
1211
"testing"
1312
"time"
1413

@@ -42,14 +41,15 @@ func TestFormatForEnvString(t *testing.T) {
4241
Path: "mysql1/password",
4342
Tags: []secretsyml.YamlTag{secretsyml.Var},
4443
}
45-
envvar := formatForEnv(
44+
k, v := formatForEnv(
4645
"dbpass",
4746
"mysecretvalue",
4847
spec,
4948
nil,
5049
)
5150

52-
So(envvar, ShouldEqual, "dbpass=mysecretvalue")
51+
So(k, ShouldEqual, "dbpass")
52+
So(v, ShouldEqual, "mysecretvalue")
5353
})
5454
Convey("For files, VALUE should be the path to a tempfile containing the secret", func() {
5555
tempFactory := NewTempFactory("")
@@ -59,16 +59,13 @@ func TestFormatForEnvString(t *testing.T) {
5959
Path: "certs/webtier1/private-cert",
6060
Tags: []secretsyml.YamlTag{secretsyml.File},
6161
}
62-
envvar := formatForEnv(
62+
key, path := formatForEnv(
6363
"SSL_CERT",
6464
"mysecretvalue",
6565
spec,
6666
&tempFactory,
6767
)
6868

69-
s := strings.Split(envvar, "=")
70-
key, path := s[0], s[1]
71-
7269
So(key, ShouldEqual, "SSL_CERT")
7370

7471
// Temp path should exist
@@ -84,8 +81,8 @@ func TestFormatForEnvString(t *testing.T) {
8481

8582
func TestJoinEnv(t *testing.T) {
8683
Convey("adds a trailing newline", t, func() {
87-
result := joinEnv([]string{"foo", "bar"})
88-
So(result, ShouldEqual, "foo\nbar\n")
84+
result := joinEnv(map[string]string{"foo": "bar", "baz": "qux"})
85+
So(result, ShouldEqual, "foo=\"bar\"\nbaz=\"qux\"\n")
8986
})
9087
}
9188

0 commit comments

Comments
 (0)