@@ -926,11 +926,11 @@ func TestReconcileServiceBindingDelete(t *testing.T) {
926
926
927
927
deleteAction := kubeActions [0 ].(clientgotesting.DeleteActionImpl )
928
928
if e , a := "delete" , deleteAction .GetVerb (); e != a {
929
- t .Fatalf ("Unexpected verb on kubeActions[1]; expected %v, got %v " , e , a )
929
+ t .Fatalf ("Unexpected verb on kubeActions[1]; %s " , expectedGot ( e , a ) )
930
930
}
931
931
932
932
if e , a := binding .Spec .SecretName , deleteAction .Name ; e != a {
933
- t .Fatalf ("Unexpected name of secret: expected %v, got %v " , e , a )
933
+ t .Fatalf ("Unexpected name of secret: %s " , expectedGot ( e , a ) )
934
934
}
935
935
936
936
actions := fakeCatalogClient .Actions ()
@@ -1142,7 +1142,7 @@ func TestReconcileServiceBindingDeleteFailedServiceBinding(t *testing.T) {
1142
1142
1143
1143
deleteAction := kubeActions [0 ].(clientgotesting.DeleteActionImpl )
1144
1144
if e , a := binding .Spec .SecretName , deleteAction .Name ; e != a {
1145
- t .Fatalf ("Unexpected name of secret: expected %v, got %v " , e , a )
1145
+ t .Fatalf ("Unexpected name of secret: %s " , expectedGot ( e , a ) )
1146
1146
}
1147
1147
1148
1148
actions := fakeCatalogClient .Actions ()
@@ -1555,7 +1555,7 @@ func TestUpdateServiceBindingCondition(t *testing.T) {
1555
1555
}
1556
1556
1557
1557
if ! reflect .DeepEqual (tc .input , inputClone ) {
1558
- t .Errorf ("%v: updating broker condition mutated input: expected %v, got %v " , tc .name , inputClone , tc .input )
1558
+ t .Errorf ("%v: updating broker condition mutated input: %s " , tc .name , expectedGot ( inputClone , tc .input ) )
1559
1559
continue
1560
1560
}
1561
1561
@@ -1581,7 +1581,7 @@ func TestUpdateServiceBindingCondition(t *testing.T) {
1581
1581
}
1582
1582
1583
1583
if e , a := 1 , len (updateActionObject .Status .Conditions ); e != a {
1584
- t .Errorf ("%v: expected %v condition(s), got %v " , tc .name , e , a )
1584
+ t .Errorf ("%v: %s " , tc .name , expectedGot ( e , a ) )
1585
1585
}
1586
1586
1587
1587
outputCondition := updateActionObject .Status .Conditions [0 ]
@@ -1595,11 +1595,11 @@ func TestUpdateServiceBindingCondition(t *testing.T) {
1595
1595
continue
1596
1596
}
1597
1597
if e , a := tc .reason , outputCondition .Reason ; e != "" && e != a {
1598
- t .Errorf ("%v: condition reasons didn't match; expected %v, got %v " , tc .name , e , a )
1598
+ t .Errorf ("%v: condition reasons didn't match; %s " , tc .name , expectedGot ( e , a ) )
1599
1599
continue
1600
1600
}
1601
1601
if e , a := tc .message , outputCondition .Message ; e != "" && e != a {
1602
- t .Errorf ("%v: condition reasons didn't match; expected %v, got %v " , tc .name , e , a )
1602
+ t .Errorf ("%v: condition reasons didn't match; %s " , tc .name , expectedGot ( e , a ) )
1603
1603
}
1604
1604
}
1605
1605
}
@@ -2013,10 +2013,10 @@ func TestReconcileBindingWithSecretConflictFailedAfterFinalRetry(t *testing.T) {
2013
2013
// second action is a get on the secret
2014
2014
action := kubeActions [1 ].(clientgotesting.GetAction )
2015
2015
if e , a := "get" , action .GetVerb (); e != a {
2016
- t .Fatalf ("Unexpected verb on action; expected %v, got %v " , e , a )
2016
+ t .Fatalf ("Unexpected verb on action; %s " , expectedGot ( e , a ) )
2017
2017
}
2018
2018
if e , a := "secrets" , action .GetResource ().Resource ; e != a {
2019
- t .Fatalf ("Unexpected resource on action; expected %v, got %v " , e , a )
2019
+ t .Fatalf ("Unexpected resource on action; %s " , expectedGot ( e , a ) )
2020
2020
}
2021
2021
2022
2022
events := getRecordedEvents (testController )
@@ -2057,7 +2057,7 @@ func TestReconcileServiceBindingWithStatusUpdateError(t *testing.T) {
2057
2057
t .Fatalf ("expected error from but got none" )
2058
2058
}
2059
2059
if e , a := "update error" , err .Error (); e != a {
2060
- t .Fatalf ("unexpected error returned: expected %q, got %q " , e , a )
2060
+ t .Fatalf ("unexpected error returned: %s " , expectedGot ( e , a ) )
2061
2061
}
2062
2062
2063
2063
brokerActions := fakeClusterServiceBrokerClient .Actions ()
@@ -2195,10 +2195,10 @@ func TestReconcileServiceBindingWithSecretParameters(t *testing.T) {
2195
2195
t .Fatalf ("unexpected type of action: expected a GetAction, got %T" , kubeActions [0 ])
2196
2196
}
2197
2197
if e , a := "secrets" , action .GetResource ().Resource ; e != a {
2198
- t .Fatalf ("Unexpected resource on action: expected %q, got %q " , e , a )
2198
+ t .Fatalf ("Unexpected resource on action: %s " , expectedGot ( e , a ) )
2199
2199
}
2200
2200
if e , a := "param-secret-name" , action .GetName (); e != a {
2201
- t .Fatalf ("Unexpected name of secret fetched: expected %q, got %q " , e , a )
2201
+ t .Fatalf ("Unexpected name of secret fetched: %s " , expectedGot ( e , a ) )
2202
2202
}
2203
2203
2204
2204
events := getRecordedEvents (testController )
@@ -2334,10 +2334,10 @@ func TestReconcileBindingWithSetOrphanMitigation(t *testing.T) {
2334
2334
assertNumberOfActions (t , kubeActions , 1 )
2335
2335
action := kubeActions [0 ].(clientgotesting.GetAction )
2336
2336
if e , a := "get" , action .GetVerb (); e != a {
2337
- t .Fatalf ("Unexpected verb on action; expected %v, got %v " , e , a )
2337
+ t .Fatalf ("Unexpected verb on action; %s " , expectedGot ( e , a ) )
2338
2338
}
2339
2339
if e , a := "namespaces" , action .GetResource ().Resource ; e != a {
2340
- t .Fatalf ("Unexpected resource on action; expected %v, got %v " , e , a )
2340
+ t .Fatalf ("Unexpected resource on action; %s " , expectedGot ( e , a ) )
2341
2341
}
2342
2342
2343
2343
actions := fakeCatalogClient .Actions ()
@@ -2402,10 +2402,10 @@ func TestReconcileBindingWithOrphanMitigationInProgress(t *testing.T) {
2402
2402
assertNumberOfActions (t , kubeActions , 1 )
2403
2403
action := kubeActions [0 ].(clientgotesting.GetAction )
2404
2404
if e , a := "delete" , action .GetVerb (); e != a {
2405
- t .Fatalf ("Unexpected verb on action; expected %v, got %v " , e , a )
2405
+ t .Fatalf ("Unexpected verb on action; %s " , expectedGot ( e , a ) )
2406
2406
}
2407
2407
if e , a := "secrets" , action .GetResource ().Resource ; e != a {
2408
- t .Fatalf ("Unexpected resource on action; expected %v, got %v " , e , a )
2408
+ t .Fatalf ("Unexpected resource on action; %s " , expectedGot ( e , a ) )
2409
2409
}
2410
2410
2411
2411
brokerActions := fakeServiceBrokerClient .Actions ()
@@ -2482,10 +2482,10 @@ func TestReconcileBindingWithOrphanMitigationReconciliationRetryTimeOut(t *testi
2482
2482
assertNumberOfActions (t , kubeActions , 1 )
2483
2483
action := kubeActions [0 ].(clientgotesting.GetAction )
2484
2484
if e , a := "delete" , action .GetVerb (); e != a {
2485
- t .Fatalf ("Unexpected verb on action; expected %v, got %v " , e , a )
2485
+ t .Fatalf ("Unexpected verb on action; %s " , expectedGot ( e , a ) )
2486
2486
}
2487
2487
if e , a := "secrets" , action .GetResource ().Resource ; e != a {
2488
- t .Fatalf ("Unexpected resource on action; expected %v, got %v " , e , a )
2488
+ t .Fatalf ("Unexpected resource on action; %s " , expectedGot ( e , a ) )
2489
2489
}
2490
2490
2491
2491
brokerActions := fakeServiceBrokerClient .Actions ()
@@ -2504,18 +2504,15 @@ func TestReconcileBindingWithOrphanMitigationReconciliationRetryTimeOut(t *testi
2504
2504
assertServiceBindingRequestFailingError (t , updatedServiceBinding , v1beta1 .ServiceBindingOperationUnbind , errorUnbindCallReason , "reason-orphan-mitigation-began" , binding )
2505
2505
assertServiceBindingOrphanMitigationSet (t , updatedServiceBinding , false )
2506
2506
2507
+ events := getRecordedEvents (testController )
2508
+
2507
2509
expectedEventPrefixes := []string {
2508
- corev1 . EventTypeWarning + " " + errorUnbindCallReason ,
2509
- corev1 . EventTypeWarning + " " + errorReconciliationRetryTimeoutReason ,
2510
+ warningEventBuilder ( errorUnbindCallReason ). String () ,
2511
+ warningEventBuilder ( errorReconciliationRetryTimeoutReason ). String () ,
2510
2512
}
2511
- events := getRecordedEvents (testController )
2512
- assertNumEvents (t , events , len (expectedEventPrefixes ))
2513
2513
2514
- for i , e := range expectedEventPrefixes {
2515
- a := events [i ]
2516
- if ! strings .HasPrefix (a , e ) {
2517
- t .Fatalf ("Received unexpected event:\n expected prefix: %v\n got: %v" , e , a )
2518
- }
2514
+ if err := checkEventPrefixes (events , expectedEventPrefixes ); err != nil {
2515
+ t .Fatal (err )
2519
2516
}
2520
2517
}
2521
2518
@@ -2576,11 +2573,11 @@ func TestReconcileServiceBindingDeleteDuringOngoingOperation(t *testing.T) {
2576
2573
2577
2574
deleteAction := kubeActions [0 ].(clientgotesting.DeleteActionImpl )
2578
2575
if e , a := "delete" , deleteAction .GetVerb (); e != a {
2579
- t .Fatalf ("Unexpected verb on kubeActions[1]; expected %v, got %v " , e , a )
2576
+ t .Fatalf ("Unexpected verb on kubeActions[1]; %s " , expectedGot ( e , a ) )
2580
2577
}
2581
2578
2582
2579
if e , a := binding .Spec .SecretName , deleteAction .Name ; e != a {
2583
- t .Fatalf ("Unexpected name of secret: expected %v, got %v " , e , a )
2580
+ t .Fatalf ("Unexpected name of secret: %s " , expectedGot ( e , a ) )
2584
2581
}
2585
2582
2586
2583
actions := fakeCatalogClient .Actions ()
@@ -2672,11 +2669,11 @@ func TestReconcileServiceBindingDeleteDuringOrphanMitigation(t *testing.T) {
2672
2669
2673
2670
deleteAction := kubeActions [0 ].(clientgotesting.DeleteActionImpl )
2674
2671
if e , a := "delete" , deleteAction .GetVerb (); e != a {
2675
- t .Fatalf ("Unexpected verb on kubeActions[1]; expected %v, got %v " , e , a )
2672
+ t .Fatalf ("Unexpected verb on kubeActions[1]; %s " , expectedGot ( e , a ) )
2676
2673
}
2677
2674
2678
2675
if e , a := binding .Spec .SecretName , deleteAction .Name ; e != a {
2679
- t .Fatalf ("Unexpected name of secret: expected %v, got %v " , e , a )
2676
+ t .Fatalf ("Unexpected name of secret: %s " , expectedGot ( e , a ) )
2680
2677
}
2681
2678
2682
2679
actions := fakeCatalogClient .Actions ()
@@ -2703,7 +2700,6 @@ func TestReconcileServiceBindingDeleteDuringOrphanMitigation(t *testing.T) {
2703
2700
assertServiceBindingOrphanMitigationSet (t , updatedServiceBinding , false )
2704
2701
2705
2702
events := getRecordedEvents (testController )
2706
- assertNumEvents (t , events , 1 )
2707
2703
2708
2704
expectedEvent := normalEventBuilder (successUnboundReason ).msg ("This binding was deleted successfully" )
2709
2705
if err := checkEvents (events , expectedEvent .stringArr ()); err != nil {
0 commit comments