@@ -63,7 +63,20 @@ func controllerSetup(startingObjects []runtime.Object, t *testing.T, stopCh <-ch
63
63
return kubeclient , fakeWatch , controller , informerFactory
64
64
}
65
65
66
- func wrapHandler (indicator chan bool , handler func (string ) error , t * testing.T ) func (string ) error {
66
+ func wrapHandler (indicator chan bool , handler func () error , t * testing.T ) func () error {
67
+ return func () error {
68
+ defer func () { indicator <- true }()
69
+
70
+ err := handler ()
71
+ if err != nil {
72
+ t .Errorf ("unexpected error: %v" , err )
73
+ }
74
+
75
+ return err
76
+ }
77
+ }
78
+
79
+ func wrapStringHandler (indicator chan bool , handler func (string ) error , t * testing.T ) func (string ) error {
67
80
return func (key string ) error {
68
81
defer func () { indicator <- true }()
69
82
@@ -129,7 +142,7 @@ func TestUpdateNewStyleSecret(t *testing.T) {
129
142
130
143
kubeclient , fakeWatch , controller , informerFactory := controllerSetup ([]runtime.Object {newStyleDockercfgSecret }, t , stopChannel )
131
144
controller .syncRegistryLocationHandler = wrapHandler (received , controller .syncRegistryLocationChange , t )
132
- controller .syncSecretHandler = wrapHandler (updatedSecret , controller .syncSecretUpdate , t )
145
+ controller .syncSecretHandler = wrapStringHandler (updatedSecret , controller .syncSecretUpdate , t )
133
146
informerFactory .Start (stopChannel )
134
147
go controller .Run (5 , stopChannel )
135
148
@@ -218,7 +231,7 @@ func TestUpdateOldStyleSecretWithKey(t *testing.T) {
218
231
219
232
kubeclient , fakeWatch , controller , informerFactory := controllerSetup ([]runtime.Object {oldStyleDockercfgSecret }, t , stopChannel )
220
233
controller .syncRegistryLocationHandler = wrapHandler (received , controller .syncRegistryLocationChange , t )
221
- controller .syncSecretHandler = wrapHandler (updatedSecret , controller .syncSecretUpdate , t )
234
+ controller .syncSecretHandler = wrapStringHandler (updatedSecret , controller .syncSecretUpdate , t )
222
235
informerFactory .Start (stopChannel )
223
236
go controller .Run (5 , stopChannel )
224
237
@@ -309,7 +322,7 @@ func TestUpdateOldStyleSecretWithoutKey(t *testing.T) {
309
322
return true , tokenSecret , nil
310
323
})
311
324
controller .syncRegistryLocationHandler = wrapHandler (received , controller .syncRegistryLocationChange , t )
312
- controller .syncSecretHandler = wrapHandler (updatedSecret , controller .syncSecretUpdate , t )
325
+ controller .syncSecretHandler = wrapStringHandler (updatedSecret , controller .syncSecretUpdate , t )
313
326
informerFactory .Start (stopChannel )
314
327
go controller .Run (5 , stopChannel )
315
328
@@ -400,17 +413,18 @@ func TestClearSecretAndRecreate(t *testing.T) {
400
413
401
414
kubeclient , fakeWatch , controller , informerFactory := controllerSetup ([]runtime.Object {registryService , oldStyleDockercfgSecret }, t , stopChannel )
402
415
controller .syncRegistryLocationHandler = wrapHandler (received , controller .syncRegistryLocationChange , t )
403
- controller .syncSecretHandler = wrapHandler (updatedSecret , controller .syncSecretUpdate , t )
416
+ controller .syncSecretHandler = wrapStringHandler (updatedSecret , controller .syncSecretUpdate , t )
404
417
informerFactory .Start (stopChannel )
405
418
go controller .Run (5 , stopChannel )
406
419
407
420
t .Log ("Waiting for ready" )
408
421
select {
409
422
case <- controller .dockerURLsInitialized :
410
423
case <- time .After (time .Duration (45 * time .Second )):
411
- t .Fatalf ("failed to become ready " )
424
+ t .Fatalf ("failed waiting for dockerURLsInitialized " )
412
425
}
413
426
427
+ t .Logf ("deleting %s service" , registryService .Name )
414
428
fakeWatch .Delete (registryService )
415
429
416
430
t .Log ("Waiting for first update" )
@@ -419,6 +433,7 @@ func TestClearSecretAndRecreate(t *testing.T) {
419
433
case <- time .After (time .Duration (45 * time .Second )):
420
434
t .Fatalf ("failed to call into syncRegistryLocationHandler" )
421
435
}
436
+
422
437
t .Log ("Waiting to update secret" )
423
438
select {
424
439
case <- updatedSecret :
@@ -449,6 +464,8 @@ func TestClearSecretAndRecreate(t *testing.T) {
449
464
}
450
465
451
466
kubeclient .ClearActions ()
467
+
468
+ t .Logf ("adding %s service" , registryService .Name )
452
469
fakeWatch .Add (registryService )
453
470
454
471
t .Log ("Waiting for second update" )
@@ -457,6 +474,7 @@ func TestClearSecretAndRecreate(t *testing.T) {
457
474
case <- time .After (time .Duration (45 * time .Second )):
458
475
t .Fatalf ("failed to call into syncRegistryLocationHandler" )
459
476
}
477
+
460
478
t .Log ("Waiting to update secret" )
461
479
select {
462
480
case <- updatedSecret :
0 commit comments