@@ -40,6 +40,8 @@ import (
40
40
clientgotesting "k8s.io/client-go/testing"
41
41
)
42
42
43
+ // TestReconcileBindingNonExistingInstance tests reconcileBinding to ensure a
44
+ // binding fails as expected when an instance to bind to doesn't exist.
43
45
func TestReconcileBindingNonExistingInstance (t * testing.T ) {
44
46
_ , fakeCatalogClient , fakeBrokerClient , testController , _ := newTestController (t , noFakeActions ())
45
47
@@ -79,6 +81,8 @@ func TestReconcileBindingNonExistingInstance(t *testing.T) {
79
81
}
80
82
}
81
83
84
+ // TestReconcileBindingNonExistingServiceClass tests reconcileBinding to ensure a
85
+ // binding fails as expected when a serviceclass does not exist.
82
86
func TestReconcileBindingNonExistingServiceClass (t * testing.T ) {
83
87
_ , fakeCatalogClient , fakeBrokerClient , testController , sharedInformers := newTestController (t , noFakeActions ())
84
88
@@ -126,6 +130,8 @@ func TestReconcileBindingNonExistingServiceClass(t *testing.T) {
126
130
}
127
131
}
128
132
133
+ // TestReconcileBindingWithSecretConflict tests reconcileBinding to ensure a
134
+ // binding with an existing secret not owned by the bindings fails as expected.
129
135
func TestReconcileBindingWithSecretConflict (t * testing.T ) {
130
136
fakeKubeClient , fakeCatalogClient , fakeBrokerClient , testController , sharedInformers := newTestController (t , fakeosb.FakeClientConfiguration {
131
137
BindReaction : & fakeosb.BindReaction {
@@ -185,7 +191,6 @@ func TestReconcileBindingWithSecretConflict(t *testing.T) {
185
191
186
192
// first action is a get on the namespace
187
193
// second action is a get on the secret
188
-
189
194
action := kubeActions [1 ].(clientgotesting.GetAction )
190
195
if e , a := "get" , action .GetVerb (); e != a {
191
196
t .Fatalf ("Unexpected verb on action; expected %v, got %v" , e , a )
@@ -203,6 +208,8 @@ func TestReconcileBindingWithSecretConflict(t *testing.T) {
203
208
}
204
209
}
205
210
211
+ // TestReconcileBindingWithParameters tests reconcileBinding to ensure a
212
+ // binding with parameters will be passed to the broker properly.
206
213
func TestReconcileBindingWithParameters (t * testing.T ) {
207
214
fakeKubeClient , fakeCatalogClient , fakeBrokerClient , testController , sharedInformers := newTestController (t , fakeosb.FakeClientConfiguration {
208
215
BindReaction : & fakeosb.BindReaction {
@@ -275,7 +282,6 @@ func TestReconcileBindingWithParameters(t *testing.T) {
275
282
276
283
// first action is a get on the namespace
277
284
// second action is a get on the secret
278
-
279
285
action := kubeActions [2 ].(clientgotesting.CreateAction )
280
286
if e , a := "create" , action .GetVerb (); e != a {
281
287
t .Fatalf ("Unexpected verb on action; expected %v, got %v" , e , a )
@@ -321,6 +327,9 @@ func TestReconcileBindingWithParameters(t *testing.T) {
321
327
}
322
328
}
323
329
330
+ // TestReconcileBindingNonbindableServiceClass tests reconcileBinding to ensure a
331
+ // binding for an instance that references a non-bindable service class and a
332
+ // non-bindable plan fails as expected.
324
333
func TestReconcileBindingNonbindableServiceClass (t * testing.T ) {
325
334
_ , fakeCatalogClient , fakeBrokerClient , testController , sharedInformers := newTestController (t , noFakeActions ())
326
335
@@ -360,6 +369,9 @@ func TestReconcileBindingNonbindableServiceClass(t *testing.T) {
360
369
}
361
370
}
362
371
372
+ // TestReconcileBindingNonbindableServiceClassBindablePlan tests reconcileBinding
373
+ // to ensure a binding for an instance that references a non-bindable service
374
+ // class and a bindable plan fails as expected.
363
375
func TestReconcileBindingNonbindableServiceClassBindablePlan (t * testing.T ) {
364
376
fakeKubeClient , fakeCatalogClient , fakeBrokerClient , testController , sharedInformers := newTestController (t , fakeosb.FakeClientConfiguration {
365
377
BindReaction : & fakeosb.BindReaction {
@@ -427,7 +439,6 @@ func TestReconcileBindingNonbindableServiceClassBindablePlan(t *testing.T) {
427
439
428
440
// first action is a get on the namespace
429
441
// second action is a get on the secret
430
-
431
442
action := kubeActions [2 ].(clientgotesting.CreateAction )
432
443
if e , a := "create" , action .GetVerb (); e != a {
433
444
t .Fatalf ("Unexpected verb on action; expected %v, got %v" , e , a )
@@ -461,6 +472,9 @@ func TestReconcileBindingNonbindableServiceClassBindablePlan(t *testing.T) {
461
472
assertNumEvents (t , events , 1 )
462
473
}
463
474
475
+ // TestReconcileBindingBindableServiceClassNonbindablePlan tests reconcileBinding
476
+ // to ensure a binding for an instance that references a bindable service class
477
+ // and a non-bindable plan fails as expected.
464
478
func TestReconcileBindingBindableServiceClassNonbindablePlan (t * testing.T ) {
465
479
_ , fakeCatalogClient , fakeBrokerClient , testController , sharedInformers := newTestController (t , noFakeActions ())
466
480
@@ -500,6 +514,9 @@ func TestReconcileBindingBindableServiceClassNonbindablePlan(t *testing.T) {
500
514
}
501
515
}
502
516
517
+ // TestReconcileBindingFailsWithInstanceAsyncOngoing tests reconcileBinding
518
+ // to ensure a binding that references an instance that has the
519
+ // AsyncOpInProgreset flag set to true fails as expected.
503
520
func TestReconcileBindingFailsWithInstanceAsyncOngoing (t * testing.T ) {
504
521
fakeKubeClient , fakeCatalogClient , fakeBrokerClient , testController , sharedInformers := newTestController (t , noFakeActions ())
505
522
@@ -553,6 +570,8 @@ func TestReconcileBindingFailsWithInstanceAsyncOngoing(t *testing.T) {
553
570
}
554
571
}
555
572
573
+ // TestReconcileBindingInstanceNotReady tests reconcileBinding to ensure a
574
+ // binding for an instance with a ready condition set to false fails as expected.
556
575
func TestReconcileBindingInstanceNotReady (t * testing.T ) {
557
576
fakeKubeClient , fakeCatalogClient , fakeBrokerClient , testController , sharedInformers := newTestController (t , noFakeActions ())
558
577
@@ -594,6 +613,8 @@ func TestReconcileBindingInstanceNotReady(t *testing.T) {
594
613
}
595
614
}
596
615
616
+ // TestReconcileBindingNamespaceError tests reconcileBinding to ensure a binding
617
+ // with an invalid namespace fails as expected.
597
618
func TestReconcileBindingNamespaceError (t * testing.T ) {
598
619
fakeKubeClient , fakeCatalogClient , fakeBrokerClient , testController , sharedInformers := newTestController (t , noFakeActions ())
599
620
@@ -635,6 +656,8 @@ func TestReconcileBindingNamespaceError(t *testing.T) {
635
656
}
636
657
}
637
658
659
+ // TestReconcileBindingDelete tests reconcileBinding to ensure a binding
660
+ // deletion works as expected.
638
661
func TestReconcileBindingDelete (t * testing.T ) {
639
662
fakeKubeClient , fakeCatalogClient , fakeBrokerClient , testController , sharedInformers := newTestController (t , fakeosb.FakeClientConfiguration {
640
663
UnbindReaction : & fakeosb.UnbindReaction {},
@@ -677,8 +700,7 @@ func TestReconcileBindingDelete(t *testing.T) {
677
700
})
678
701
679
702
kubeActions := fakeKubeClient .Actions ()
680
- // The two actions should be:
681
- // 0. Deleting the secret
703
+ // The action should be deleting the secret
682
704
assertNumberOfActions (t , kubeActions , 1 )
683
705
684
706
deleteAction := kubeActions [0 ].(clientgotesting.DeleteActionImpl )
@@ -925,6 +947,8 @@ func TestReconcileBindingDeleteFailedBinding(t *testing.T) {
925
947
}
926
948
}
927
949
950
+ // TestReconcileBindingWithBrokerError tests reconcileBinding to ensure a
951
+ // binding request response that contains a broker error fails as expected.
928
952
func TestReconcileBindingWithBrokerError (t * testing.T ) {
929
953
_ , _ , _ , testController , sharedInformers := newTestController (t , fakeosb.FakeClientConfiguration {
930
954
BindReaction : & fakeosb.BindReaction {
@@ -966,6 +990,8 @@ func TestReconcileBindingWithBrokerError(t *testing.T) {
966
990
}
967
991
}
968
992
993
+ // TestReconcileBindingWithBrokerHTTPError tests reconcileBindings to ensure a
994
+ // binding request response that contains a broker HTTP error fails as expected.
969
995
func TestReconcileBindingWithBrokerHTTPError (t * testing.T ) {
970
996
_ , _ , _ , testController , sharedInformers := newTestController (t , fakeosb.FakeClientConfiguration {
971
997
BindReaction : & fakeosb.BindReaction {
@@ -1155,6 +1181,22 @@ func TestReconcileBindingWithBindingFailure(t *testing.T) {
1155
1181
}
1156
1182
}
1157
1183
1184
+ // TestUpdateBindingCondition tests updateBindingCondition to ensure all status
1185
+ // condition transitions on a binding work as expected.
1186
+ //
1187
+ // The test cases are proving:
1188
+ // - a binding with no status that has status condition set to false will update
1189
+ // the transition time
1190
+ // - a binding with condition false set to condition false will not update the
1191
+ // transition time
1192
+ // - a binding with condition false set to condition false with a new message and
1193
+ // reason will not update the transition time
1194
+ // - a binding with condition false set to condition true will update the
1195
+ // transition time
1196
+ // - a binding with condition status true set to true will not update the
1197
+ // transition time
1198
+ // - a binding with condition status true set to false will update the transition
1199
+ // time
1158
1200
func TestUpdateBindingCondition (t * testing.T ) {
1159
1201
getTestBindingWithStatus := func (status v1alpha1.ConditionStatus ) * v1alpha1.Binding {
1160
1202
instance := getTestBinding ()
@@ -1170,6 +1212,13 @@ func TestUpdateBindingCondition(t *testing.T) {
1170
1212
return instance
1171
1213
}
1172
1214
1215
+ // Anonymous struct fields:
1216
+ // name: short description of the test
1217
+ // input: the binding to test
1218
+ // status: condition status to set for binding condition
1219
+ // reason: reason to set for binding condition
1220
+ // message: message to set for binding condition
1221
+ // transitionTimeChanged: toggle for verifying transition time was updated
1173
1222
cases := []struct {
1174
1223
name string
1175
1224
input * v1alpha1.Binding
@@ -1285,6 +1334,8 @@ func TestUpdateBindingCondition(t *testing.T) {
1285
1334
}
1286
1335
}
1287
1336
1337
+ // TestReconcileUnbindingWithBrokerError tests reconcileBinding to ensure an
1338
+ // unbinding request response that contains a broker error fails as expected.
1288
1339
func TestReconcileUnbindingWithBrokerError (t * testing.T ) {
1289
1340
_ , _ , _ , testController , sharedInformers := newTestController (t , fakeosb.FakeClientConfiguration {
1290
1341
UnbindReaction : & fakeosb.UnbindReaction {
@@ -1327,6 +1378,9 @@ func TestReconcileUnbindingWithBrokerError(t *testing.T) {
1327
1378
}
1328
1379
}
1329
1380
1381
+ // TestReconcileUnbindingWithBrokerHTTPError tests reconcileBinding to ensure an
1382
+ // unbinding request response that contains a broker HTTP error fails as
1383
+ // expected.
1330
1384
func TestReconcileUnbindingWithBrokerHTTPError (t * testing.T ) {
1331
1385
_ , _ , _ , testController , sharedInformers := newTestController (t , fakeosb.FakeClientConfiguration {
1332
1386
UnbindReaction : & fakeosb.UnbindReaction {
0 commit comments