forked from nginx-proxy/docker-gen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reflect_test.go
61 lines (52 loc) · 1.21 KB
/
reflect_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
package dockergen
import "testing"
func TestDeepGetNoPath(t *testing.T) {
item := RuntimeContainer{}
value := deepGet(item, "")
if _, ok := value.(RuntimeContainer); !ok {
t.Fail()
}
var returned RuntimeContainer
returned = value.(RuntimeContainer)
if !returned.Equals(item) {
t.Fail()
}
}
func TestDeepGetSimple(t *testing.T) {
item := RuntimeContainer{
ID: "expected",
}
value := deepGet(item, "ID")
if _, ok := value.(string); !ok {
t.Errorf("expected: %#v. got: %#v", "expected", value)
}
if value != "expected" {
t.Errorf("expected: %s. got: %s", "expected", value)
}
}
func TestDeepGetSimpleDotPrefix(t *testing.T) {
item := RuntimeContainer{
ID: "expected",
}
value := deepGet(item, "...ID")
if _, ok := value.(string); !ok {
t.Errorf("expected: %#v. got: %#v", "expected", value)
}
if value != "expected" {
t.Errorf("expected: %s. got: %s", "expected", value)
}
}
func TestDeepGetMap(t *testing.T) {
item := RuntimeContainer{
Env: map[string]string{
"key": "value",
},
}
value := deepGet(item, "Env.key")
if _, ok := value.(string); !ok {
t.Errorf("expected: %#v. got: %#v", "value", value)
}
if value != "value" {
t.Errorf("expected: %s. got: %s", "value", value)
}
}