-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain_test.go
More file actions
52 lines (48 loc) · 995 Bytes
/
main_test.go
File metadata and controls
52 lines (48 loc) · 995 Bytes
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 main
import (
"reflect"
"testing"
)
func TestParseWatchNamespaces(t *testing.T) {
t.Parallel()
tests := []struct {
name string
raw string
want []string
}{
{
name: "empty",
raw: "",
want: nil,
},
{
name: "whitespace only",
raw: " ",
want: nil,
},
{
name: "single namespace",
raw: "spritz-staging",
want: []string{"spritz-staging"},
},
{
name: "multiple namespaces",
raw: "spritz-staging,spritz-system-staging",
want: []string{"spritz-staging", "spritz-system-staging"},
},
{
name: "trims and deduplicates",
raw: " spritz-staging , spritz-system-staging , spritz-staging ,, ",
want: []string{"spritz-staging", "spritz-system-staging"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got := parseWatchNamespaces(tt.raw)
if !reflect.DeepEqual(got, tt.want) {
t.Fatalf("parseWatchNamespaces(%q) = %#v, want %#v", tt.raw, got, tt.want)
}
})
}
}