@@ -33,9 +33,10 @@ func Test_UpdateApplication(t *testing.T) {
33
33
t .Run ("Test successful update" , func (t * testing.T ) {
34
34
mockClientFn := func (endpoint * registry.RegistryEndpoint , username , password string ) (registry.RegistryClient , error ) {
35
35
regMock := regmock.RegistryClient {}
36
- regMock .On ("Tags " , mock .MatchedBy (func (s string ) bool {
36
+ regMock .On ("NewRepository " , mock .MatchedBy (func (s string ) bool {
37
37
return s == "jannfis/foobar"
38
- })).Return ([]string {"1.0.1" }, nil )
38
+ })).Return (nil )
39
+ regMock .On ("Tags" ).Return ([]string {"1.0.1" }, nil )
39
40
return & regMock , nil
40
41
}
41
42
@@ -91,7 +92,10 @@ func Test_UpdateApplication(t *testing.T) {
91
92
mockClientFn := func (endpoint * registry.RegistryEndpoint , username , password string ) (registry.RegistryClient , error ) {
92
93
regMock := regmock.RegistryClient {}
93
94
assert .Equal (t , endpoint .RegistryPrefix , "quay.io" )
94
- regMock .On ("Tags" , mock .Anything ).Return ([]string {"1.0.1" }, nil )
95
+ regMock .On ("NewRepository" , mock .MatchedBy (func (s string ) bool {
96
+ return s == "jannfis/foobar"
97
+ })).Return (nil )
98
+ regMock .On ("Tags" ).Return ([]string {"1.0.1" }, nil )
95
99
return & regMock , nil
96
100
}
97
101
@@ -152,9 +156,10 @@ func Test_UpdateApplication(t *testing.T) {
152
156
mockClientFn := func (endpoint * registry.RegistryEndpoint , username , password string ) (registry.RegistryClient , error ) {
153
157
regMock := regmock.RegistryClient {}
154
158
assert .Equal (t , endpoint .RegistryPrefix , "quay.io" )
155
- regMock .On ("Tags " , mock .MatchedBy (func (s string ) bool {
159
+ regMock .On ("NewRepository " , mock .MatchedBy (func (s string ) bool {
156
160
return s == "someorg/foobar"
157
- })).Return ([]string {"1.0.1" }, nil )
161
+ })).Return (nil )
162
+ regMock .On ("Tags" ).Return ([]string {"1.0.1" }, nil )
158
163
return & regMock , nil
159
164
}
160
165
@@ -214,6 +219,7 @@ func Test_UpdateApplication(t *testing.T) {
214
219
t .Run ("Test successful update when no tag is set in running workload" , func (t * testing.T ) {
215
220
mockClientFn := func (endpoint * registry.RegistryEndpoint , username , password string ) (registry.RegistryClient , error ) {
216
221
regMock := regmock.RegistryClient {}
222
+ regMock .On ("NewRepository" , mock .Anything ).Return (nil )
217
223
regMock .On ("Tags" , mock .Anything ).Return ([]string {"1.0.1" }, nil )
218
224
return & regMock , nil
219
225
}
@@ -271,6 +277,7 @@ func Test_UpdateApplication(t *testing.T) {
271
277
regMock := regmock.RegistryClient {}
272
278
assert .Equal (t , "myuser" , username )
273
279
assert .Equal (t , "mypass" , password )
280
+ regMock .On ("NewRepository" , mock .Anything ).Return (nil )
274
281
regMock .On ("Tags" , mock .Anything ).Return ([]string {"1.0.1" }, nil )
275
282
return & regMock , nil
276
283
}
@@ -384,6 +391,7 @@ func Test_UpdateApplication(t *testing.T) {
384
391
t .Run ("Test skip because of image up-to-date" , func (t * testing.T ) {
385
392
mockClientFn := func (endpoint * registry.RegistryEndpoint , username , password string ) (registry.RegistryClient , error ) {
386
393
regMock := regmock.RegistryClient {}
394
+ regMock .On ("NewRepository" , mock .Anything ).Return (nil )
387
395
regMock .On ("Tags" , mock .Anything ).Return ([]string {"1.0.1" }, nil )
388
396
return & regMock , nil
389
397
}
@@ -439,6 +447,7 @@ func Test_UpdateApplication(t *testing.T) {
439
447
t .Run ("Test update because of image registry changed" , func (t * testing.T ) {
440
448
mockClientFn := func (endpoint * registry.RegistryEndpoint , username , password string ) (registry.RegistryClient , error ) {
441
449
regMock := regmock.RegistryClient {}
450
+ regMock .On ("NewRepository" , mock .Anything ).Return (nil )
442
451
regMock .On ("Tags" , mock .Anything ).Return ([]string {"1.0.1" }, nil )
443
452
return & regMock , nil
444
453
}
@@ -497,6 +506,7 @@ func Test_UpdateApplication(t *testing.T) {
497
506
t .Run ("Test not updated because kustomize image is the same" , func (t * testing.T ) {
498
507
mockClientFn := func (endpoint * registry.RegistryEndpoint , username , password string ) (registry.RegistryClient , error ) {
499
508
regMock := regmock.RegistryClient {}
509
+ regMock .On ("NewRepository" , mock .Anything ).Return (nil )
500
510
regMock .On ("Tags" , mock .Anything ).Return ([]string {"1.0.1" }, nil )
501
511
return & regMock , nil
502
512
}
@@ -569,8 +579,9 @@ func Test_UpdateApplication(t *testing.T) {
569
579
called := 0
570
580
mockClientFn := func (endpoint * registry.RegistryEndpoint , username , password string ) (registry.RegistryClient , error ) {
571
581
regMock := regmock.RegistryClient {}
582
+ regMock .On ("NewRepository" , mock .Anything ).Return (nil )
572
583
regMock .On ("Tags" , mock .Anything ).Return ([]string {"one" , "two" , "three" , "four" }, nil )
573
- regMock .On ("ManifestV1 " , mock .Anything ).Return (meta [called ], nil )
584
+ regMock .On ("Manifest " , mock .Anything ).Return (meta [called ], nil )
574
585
called += 1
575
586
return & regMock , nil
576
587
}
@@ -644,8 +655,9 @@ func Test_UpdateApplication(t *testing.T) {
644
655
called := 0
645
656
mockClientFn := func (endpoint * registry.RegistryEndpoint , username , password string ) (registry.RegistryClient , error ) {
646
657
regMock := regmock.RegistryClient {}
658
+ regMock .On ("NewRepository" , mock .Anything ).Return (nil )
647
659
regMock .On ("Tags" , mock .Anything ).Return ([]string {"one" , "two" , "three" , "four" }, nil )
648
- regMock .On ("ManifestV1 " , mock .Anything ).Return (meta [called ], nil )
660
+ regMock .On ("Manifest " , mock .Anything ).Return (meta [called ], nil )
649
661
called += 1
650
662
return & regMock , nil
651
663
}
@@ -705,6 +717,7 @@ func Test_UpdateApplication(t *testing.T) {
705
717
t .Run ("Error - unknown registry" , func (t * testing.T ) {
706
718
mockClientFn := func (endpoint * registry.RegistryEndpoint , username , password string ) (registry.RegistryClient , error ) {
707
719
regMock := regmock.RegistryClient {}
720
+ regMock .On ("NewRepository" , mock .Anything ).Return (nil )
708
721
regMock .On ("Tags" , mock .Anything ).Return ([]string {"1.0.1" }, nil )
709
722
return & regMock , nil
710
723
}
@@ -813,6 +826,7 @@ func Test_UpdateApplication(t *testing.T) {
813
826
t .Run ("Test error on failure to list tags" , func (t * testing.T ) {
814
827
mockClientFn := func (endpoint * registry.RegistryEndpoint , username , password string ) (registry.RegistryClient , error ) {
815
828
regMock := regmock.RegistryClient {}
829
+ regMock .On ("NewRepository" , mock .Anything ).Return (nil )
816
830
regMock .On ("Tags" , mock .Anything ).Return (nil , errors .New ("some error" ))
817
831
return & regMock , nil
818
832
}
@@ -868,6 +882,7 @@ func Test_UpdateApplication(t *testing.T) {
868
882
t .Run ("Test error on improper semver in tag" , func (t * testing.T ) {
869
883
mockClientFn := func (endpoint * registry.RegistryEndpoint , username , password string ) (registry.RegistryClient , error ) {
870
884
regMock := regmock.RegistryClient {}
885
+ regMock .On ("NewRepository" , mock .Anything ).Return (nil )
871
886
regMock .On ("Tags" , mock .Anything ).Return ([]string {"1.0.0" , "1.0.1" }, nil )
872
887
return & regMock , nil
873
888
}
0 commit comments