forked from zalando-incubator/es-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
label_selector_test.go
53 lines (46 loc) · 974 Bytes
/
label_selector_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 main
import "testing"
func TestLabelsString(t *testing.T) {
labels := Labels(map[string]string{
"master": "true",
})
expected := "master=true"
if labels.String() != expected {
t.Errorf("expected %s, got %s", expected, labels.String())
}
}
func TestSetLabelsValue(t *testing.T) {
for _, tc := range []struct {
msg string
value string
valid bool
}{
{
msg: "test valid labels",
value: "master=true,worker=false",
valid: true,
},
{
msg: "test invalid labels",
value: "master=true=false",
valid: false,
},
} {
t.Run(tc.msg, func(t *testing.T) {
labels := Labels(map[string]string{})
err := labels.Set(tc.value)
if err != nil && tc.valid {
t.Errorf("should not fail: %s", err)
}
if err == nil && !tc.valid {
t.Error("expected failure")
}
})
}
}
func TestLabelsIsCumulative(t *testing.T) {
var labels Labels
if !labels.IsCumulative() {
t.Error("expected IsCumulative = true")
}
}