-
Notifications
You must be signed in to change notification settings - Fork 14
/
container_envvar_test.go
62 lines (58 loc) · 1.28 KB
/
container_envvar_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
54
55
56
57
58
59
60
61
62
package libyaml_test
import (
"reflect"
"testing"
. "github.com/replicatedhq/libyaml"
yaml "gopkg.in/yaml.v2"
)
func TestContainerEnvVar(t *testing.T) {
cases := []struct {
name string
yaml string
expected ContainerEnvVar
err error
}{
{
name: "with static_val",
yaml: "name: ENV1\nstatic_val: static\nis_excluded_from_support: true\nwhen: true",
expected: ContainerEnvVar{
Name: "ENV1",
Value: "static",
StaticVal: "static",
IsExcludedFromSupport: "true",
When: "true",
},
},
{
name: "with value",
yaml: "name: ENV2\nvalue: static",
expected: ContainerEnvVar{
Name: "ENV2",
Value: "static",
StaticVal: "static",
},
},
{
name: "with no value",
yaml: "name: ENV3",
expected: ContainerEnvVar{
Name: "ENV3",
},
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
var envVar ContainerEnvVar
err := yaml.Unmarshal([]byte(c.yaml), &envVar)
if c.err != nil {
if err == nil {
t.Error("Expecting error, got nil")
}
} else if err != nil {
t.Errorf("Got unexpected error: %v", err)
} else if !reflect.DeepEqual(c.expected, envVar) {
t.Errorf("Expecting %+v, got %+v", c.expected, envVar)
}
})
}
}