forked from ericchiang/k8s
-
Notifications
You must be signed in to change notification settings - Fork 1
/
labels_test.go
52 lines (49 loc) · 1018 Bytes
/
labels_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 k8s
import "testing"
func TestLabelSelector(t *testing.T) {
tests := []struct {
f func(l *LabelSelector)
want string
}{
{
f: func(l *LabelSelector) {
l.Eq("component", "frontend")
},
want: "component=frontend",
},
{
f: func(l *LabelSelector) {
l.Eq("kubernetes.io/role", "master")
},
want: "kubernetes.io/role=master",
},
{
f: func(l *LabelSelector) {
l.In("type", "prod", "staging")
l.Eq("component", "frontend")
},
want: "type in (prod, staging),component=frontend",
},
{
f: func(l *LabelSelector) {
l.NotIn("type", "prod", "staging")
l.NotEq("component", "frontend")
},
want: "type notin (prod, staging),component!=frontend",
},
{
f: func(l *LabelSelector) {
l.Eq("foo", "I am not a valid label value")
},
want: "",
},
}
for i, test := range tests {
l := new(LabelSelector)
test.f(l)
got := l.String()
if test.want != got {
t.Errorf("case %d: want=%q, got=%q", i, test.want, got)
}
}
}