@@ -19,6 +19,13 @@ func TestMatchesNoIngressClass(t *testing.T) {
19
19
"kubernetes.io/ingress.class" : "test" ,
20
20
"switchboard.borchero.com/ignore" : "true" ,
21
21
}))
22
+ assert .False (t , selector .Matches (map [string ]string {
23
+ "switchboard.borchero.com/ignore" : "all" ,
24
+ }))
25
+ assert .False (t , selector .Matches (map [string ]string {
26
+ "kubernetes.io/ingress.class" : "test" ,
27
+ "switchboard.borchero.com/ignore" : "all" ,
28
+ }))
22
29
}
23
30
24
31
func TestMatchesIngressClass (t * testing.T ) {
@@ -42,4 +49,58 @@ func TestMatchesIngressClass(t *testing.T) {
42
49
"kubernetes.io/ingress.class" : "ingress" ,
43
50
"switchboard.borchero.com/ignore" : "true" ,
44
51
}))
52
+ assert .False (t , selector .Matches (map [string ]string {
53
+ "switchboard.borchero.com/ignore" : "all" ,
54
+ }))
55
+ assert .False (t , selector .Matches (map [string ]string {
56
+ "kubernetes.io/ingress.class" : "test" ,
57
+ "switchboard.borchero.com/ignore" : "all" ,
58
+ }))
59
+ assert .False (t , selector .Matches (map [string ]string {
60
+ "kubernetes.io/ingress.class" : "ingress" ,
61
+ "switchboard.borchero.com/ignore" : "all" ,
62
+ }))
63
+ }
64
+
65
+ func TestMatchesIntegration (t * testing.T ) {
66
+ cls := "ingress"
67
+ selector := NewSelector (& cls )
68
+
69
+ // Ignore all
70
+ assert .False (t , selector .MatchesIntegration (map [string ]string {
71
+ "switchboard.borchero.com/ignore" : "true" ,
72
+ }, "external-dns" ))
73
+ assert .False (t , selector .MatchesIntegration (map [string ]string {
74
+ "switchboard.borchero.com/ignore" : "all" ,
75
+ }, "external-dns" ))
76
+
77
+ // Ignore only one
78
+ assert .False (t , selector .MatchesIntegration (map [string ]string {
79
+ "switchboard.borchero.com/ignore" : "external-dns" ,
80
+ }, "external-dns" ))
81
+ assert .True (t , selector .MatchesIntegration (map [string ]string {
82
+ "switchboard.borchero.com/ignore" : "cert-manager" ,
83
+ }, "external-dns" ))
84
+
85
+ // Ignore multiple
86
+ assert .False (t , selector .MatchesIntegration (map [string ]string {
87
+ "switchboard.borchero.com/ignore" : "external-dns,cert-manager" ,
88
+ }, "external-dns" ))
89
+ assert .False (t , selector .MatchesIntegration (map [string ]string {
90
+ "switchboard.borchero.com/ignore" : "external-dns,cert-manager" ,
91
+ }, "cert-manager" ))
92
+ assert .True (t , selector .MatchesIntegration (map [string ]string {
93
+ "switchboard.borchero.com/ignore" : "external-dns,cert-manager" ,
94
+ }, "unknown" ))
95
+
96
+ // Ignore with space in between
97
+ assert .False (t , selector .MatchesIntegration (map [string ]string {
98
+ "switchboard.borchero.com/ignore" : "external-dns, cert-manager" ,
99
+ }, "external-dns" ))
100
+ assert .False (t , selector .MatchesIntegration (map [string ]string {
101
+ "switchboard.borchero.com/ignore" : "external-dns, cert-manager" ,
102
+ }, "cert-manager" ))
103
+ assert .True (t , selector .MatchesIntegration (map [string ]string {
104
+ "switchboard.borchero.com/ignore" : "external-dns, cert-manager" ,
105
+ }, "unknown" ))
45
106
}
0 commit comments