@@ -6,6 +6,21 @@ import (
6
6
"github.com/stretchr/testify/assert"
7
7
)
8
8
9
+ func TestKustomizeImage_Match (t * testing.T ) {
10
+ // no prefix
11
+ assert .False (t , KustomizeImage ("foo=1" ).Match ("bar=1" ))
12
+ // mismatched delimiter
13
+ assert .False (t , KustomizeImage ("foo=1" ).Match ("bar:1" ))
14
+ assert .False (t , KustomizeImage ("foo:1" ).Match ("bar=1" ))
15
+ assert .False (t , KustomizeImage ("foobar:2" ).Match ("foo:2" ))
16
+ assert .False (t , KustomizeImage ("foobar@2" ).Match ("foo@2" ))
17
+ // matches
18
+ assert .True (t , KustomizeImage ("foo=1" ).Match ("foo=2" ))
19
+ assert .True (t , KustomizeImage ("foo:1" ).Match ("foo:2" ))
20
+ assert .True (t , KustomizeImage ("foo@1" ).Match ("foo@2" ))
21
+ assert .True (t , KustomizeImage ("nginx" ).Match ("nginx" ))
22
+ }
23
+
9
24
func Test_KustomizeImages_Find (t * testing.T ) {
10
25
images := KustomizeImages {
11
26
"a/b:1.0" ,
@@ -17,10 +32,10 @@ func Test_KustomizeImages_Find(t *testing.T) {
17
32
for _ , image := range images {
18
33
assert .True (t , images .Find (image ) >= 0 )
19
34
}
20
- for _ , image := range []string {"a/b:2" , "x/y=foo.bar" } {
35
+ for _ , image := range []string {"a/b" , "a/b :2" , "x/y=foo.bar" } {
21
36
assert .True (t , images .Find (KustomizeImage (image )) >= 0 )
22
37
}
23
- for _ , image := range []string {"a/b" , " x" , "x/y" } {
38
+ for _ , image := range []string {"x" , "x/y" } {
24
39
assert .Equal (t , - 1 , images .Find (KustomizeImage (image )))
25
40
}
26
41
}
0 commit comments