-
Notifications
You must be signed in to change notification settings - Fork 3
/
config_test.go
53 lines (48 loc) · 913 Bytes
/
config_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
53
package bw_test
import (
. "github.com/james-lawrence/bw"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func environmentSet1(k string) string {
switch k {
case "FOO":
return "BAR"
case "BIZZ":
return "BAZZ"
case "MULTILINE":
return "line1\nline2\nline3"
default:
return ""
}
}
type xType struct {
Field1 string
Field2 string
Field3 string
}
var _ = Describe("Config", func() {
DescribeTable("ExpandEnvironAndDecode", func(content string, result xType) {
out := xType{}
Expect(ExpandEnvironAndDecode([]byte(content), &out, environmentSet1)).ToNot(HaveOccurred())
Expect(out).To(Equal(result))
},
Entry("example 1",
`field1: "${FOO}"
field2: "${BIZZ}"
field3: "YOINK"
`,
xType{
Field1: "BAR",
Field2: "BAZZ",
Field3: "YOINK",
},
),
Entry("example 2",
`field1: '${MULTILINE}'`,
xType{
Field1: "line1\nline2\nline3",
},
),
)
})