forked from cloudfoundry-community/go-cfenv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvmap_test.go
52 lines (43 loc) · 1.17 KB
/
envmap_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
package cfenv
import (
"testing"
. "github.com/onsi/gomega"
"github.com/sclevine/spec"
)
func testEnvMap(t *testing.T, when spec.G, it spec.S) {
it.Before(func() {
RegisterTestingT(t)
})
test := func(input string, expectedKey string, expectedValue string) {
k, v := splitEnv(input)
Expect(k).To(Equal(expectedKey))
Expect(v).To(Equal(expectedValue))
}
when("splitting environment variables", func() {
when("with empty env var", func() {
it("should have empty value", func() {
test("", "", "")
})
})
when("with env var not split by equals", func() {
it("should have empty value", func() {
test("TEST", "TEST", "")
})
})
when("with env var split by equals but no value", func() {
it("should have empty value", func() {
test("TEST=", "TEST", "")
})
})
when("with env var split by equals with key and value", func() {
it("should have non-empty key and value", func() {
test("TEST=VAL", "TEST", "VAL")
})
})
when("with env var split by equals with key and value containing equals", func() {
it("should have non-empty key and value", func() {
test("TEST=VAL=OTHERVAL", "TEST", "VAL=OTHERVAL")
})
})
})
}