@@ -68,7 +68,7 @@ func TestWaitForDeletion(t *testing.T) {
68
68
69
69
tests := []struct {
70
70
name string
71
- info * resource.Info
71
+ infos [] * resource.Info
72
72
fakeClient func () * dynamicfakeclient.FakeDynamicClient
73
73
timeout time.Duration
74
74
uidMap UIDMap
@@ -78,12 +78,14 @@ func TestWaitForDeletion(t *testing.T) {
78
78
}{
79
79
{
80
80
name : "missing on get" ,
81
- info : & resource.Info {
82
- Mapping : & meta.RESTMapping {
83
- Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
81
+ infos : []* resource.Info {
82
+ {
83
+ Mapping : & meta.RESTMapping {
84
+ Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
85
+ },
86
+ Name : "name-foo" ,
87
+ Namespace : "ns-foo" ,
84
88
},
85
- Name : "name-foo" ,
86
- Namespace : "ns-foo" ,
87
89
},
88
90
fakeClient : func () * dynamicfakeclient.FakeDynamicClient {
89
91
return dynamicfakeclient .NewSimpleDynamicClient (scheme )
@@ -99,14 +101,31 @@ func TestWaitForDeletion(t *testing.T) {
99
101
}
100
102
},
101
103
},
104
+ {
105
+ name : "handles no infos" ,
106
+ infos : []* resource.Info {},
107
+ fakeClient : func () * dynamicfakeclient.FakeDynamicClient {
108
+ return dynamicfakeclient .NewSimpleDynamicClient (scheme )
109
+ },
110
+ timeout : 10 * time .Second ,
111
+ expectedErr : errNoMatchingResources .Error (),
112
+
113
+ validateActions : func (t * testing.T , actions []clienttesting.Action ) {
114
+ if len (actions ) != 0 {
115
+ t .Fatal (spew .Sdump (actions ))
116
+ }
117
+ },
118
+ },
102
119
{
103
120
name : "uid conflict on get" ,
104
- info : & resource.Info {
105
- Mapping : & meta.RESTMapping {
106
- Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
121
+ infos : []* resource.Info {
122
+ {
123
+ Mapping : & meta.RESTMapping {
124
+ Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
125
+ },
126
+ Name : "name-foo" ,
127
+ Namespace : "ns-foo" ,
107
128
},
108
- Name : "name-foo" ,
109
- Namespace : "ns-foo" ,
110
129
},
111
130
fakeClient : func () * dynamicfakeclient.FakeDynamicClient {
112
131
fakeClient := dynamicfakeclient .NewSimpleDynamicClient (scheme )
@@ -146,12 +165,14 @@ func TestWaitForDeletion(t *testing.T) {
146
165
},
147
166
{
148
167
name : "times out" ,
149
- info : & resource.Info {
150
- Mapping : & meta.RESTMapping {
151
- Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
168
+ infos : []* resource.Info {
169
+ {
170
+ Mapping : & meta.RESTMapping {
171
+ Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
172
+ },
173
+ Name : "name-foo" ,
174
+ Namespace : "ns-foo" ,
152
175
},
153
- Name : "name-foo" ,
154
- Namespace : "ns-foo" ,
155
176
},
156
177
fakeClient : func () * dynamicfakeclient.FakeDynamicClient {
157
178
fakeClient := dynamicfakeclient .NewSimpleDynamicClient (scheme )
@@ -177,12 +198,14 @@ func TestWaitForDeletion(t *testing.T) {
177
198
},
178
199
{
179
200
name : "handles watch close out" ,
180
- info : & resource.Info {
181
- Mapping : & meta.RESTMapping {
182
- Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
201
+ infos : []* resource.Info {
202
+ {
203
+ Mapping : & meta.RESTMapping {
204
+ Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
205
+ },
206
+ Name : "name-foo" ,
207
+ Namespace : "ns-foo" ,
183
208
},
184
- Name : "name-foo" ,
185
- Namespace : "ns-foo" ,
186
209
},
187
210
fakeClient : func () * dynamicfakeclient.FakeDynamicClient {
188
211
fakeClient := dynamicfakeclient .NewSimpleDynamicClient (scheme )
@@ -228,12 +251,14 @@ func TestWaitForDeletion(t *testing.T) {
228
251
},
229
252
{
230
253
name : "handles watch delete" ,
231
- info : & resource.Info {
232
- Mapping : & meta.RESTMapping {
233
- Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
254
+ infos : []* resource.Info {
255
+ {
256
+ Mapping : & meta.RESTMapping {
257
+ Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
258
+ },
259
+ Name : "name-foo" ,
260
+ Namespace : "ns-foo" ,
234
261
},
235
- Name : "name-foo" ,
236
- Namespace : "ns-foo" ,
237
262
},
238
263
fakeClient : func () * dynamicfakeclient.FakeDynamicClient {
239
264
fakeClient := dynamicfakeclient .NewSimpleDynamicClient (scheme )
@@ -267,7 +292,7 @@ func TestWaitForDeletion(t *testing.T) {
267
292
t .Run (test .name , func (t * testing.T ) {
268
293
fakeClient := test .fakeClient ()
269
294
o := & WaitOptions {
270
- ResourceFinder : genericclioptions .NewSimpleFakeResourceFinder (test .info ),
295
+ ResourceFinder : genericclioptions .NewSimpleFakeResourceFinder (test .infos ... ),
271
296
UIDMap : test .uidMap ,
272
297
DynamicClient : fakeClient ,
273
298
Timeout : test .timeout ,
@@ -299,7 +324,7 @@ func TestWaitForCondition(t *testing.T) {
299
324
300
325
tests := []struct {
301
326
name string
302
- info * resource.Info
327
+ infos [] * resource.Info
303
328
fakeClient func () * dynamicfakeclient.FakeDynamicClient
304
329
timeout time.Duration
305
330
@@ -308,12 +333,14 @@ func TestWaitForCondition(t *testing.T) {
308
333
}{
309
334
{
310
335
name : "present on get" ,
311
- info : & resource.Info {
312
- Mapping : & meta.RESTMapping {
313
- Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
336
+ infos : []* resource.Info {
337
+ {
338
+ Mapping : & meta.RESTMapping {
339
+ Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
340
+ },
341
+ Name : "name-foo" ,
342
+ Namespace : "ns-foo" ,
314
343
},
315
- Name : "name-foo" ,
316
- Namespace : "ns-foo" ,
317
344
},
318
345
fakeClient : func () * dynamicfakeclient.FakeDynamicClient {
319
346
fakeClient := dynamicfakeclient .NewSimpleDynamicClient (scheme )
@@ -336,14 +363,31 @@ func TestWaitForCondition(t *testing.T) {
336
363
}
337
364
},
338
365
},
366
+ {
367
+ name : "handles no infos" ,
368
+ infos : []* resource.Info {},
369
+ fakeClient : func () * dynamicfakeclient.FakeDynamicClient {
370
+ return dynamicfakeclient .NewSimpleDynamicClient (scheme )
371
+ },
372
+ timeout : 10 * time .Second ,
373
+ expectedErr : errNoMatchingResources .Error (),
374
+
375
+ validateActions : func (t * testing.T , actions []clienttesting.Action ) {
376
+ if len (actions ) != 0 {
377
+ t .Fatal (spew .Sdump (actions ))
378
+ }
379
+ },
380
+ },
339
381
{
340
382
name : "times out" ,
341
- info : & resource.Info {
342
- Mapping : & meta.RESTMapping {
343
- Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
383
+ infos : []* resource.Info {
384
+ {
385
+ Mapping : & meta.RESTMapping {
386
+ Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
387
+ },
388
+ Name : "name-foo" ,
389
+ Namespace : "ns-foo" ,
344
390
},
345
- Name : "name-foo" ,
346
- Namespace : "ns-foo" ,
347
391
},
348
392
fakeClient : func () * dynamicfakeclient.FakeDynamicClient {
349
393
fakeClient := dynamicfakeclient .NewSimpleDynamicClient (scheme )
@@ -372,12 +416,14 @@ func TestWaitForCondition(t *testing.T) {
372
416
},
373
417
{
374
418
name : "handles watch close out" ,
375
- info : & resource.Info {
376
- Mapping : & meta.RESTMapping {
377
- Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
419
+ infos : []* resource.Info {
420
+ {
421
+ Mapping : & meta.RESTMapping {
422
+ Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
423
+ },
424
+ Name : "name-foo" ,
425
+ Namespace : "ns-foo" ,
378
426
},
379
- Name : "name-foo" ,
380
- Namespace : "ns-foo" ,
381
427
},
382
428
fakeClient : func () * dynamicfakeclient.FakeDynamicClient {
383
429
fakeClient := dynamicfakeclient .NewSimpleDynamicClient (scheme )
@@ -423,12 +469,14 @@ func TestWaitForCondition(t *testing.T) {
423
469
},
424
470
{
425
471
name : "handles watch condition change" ,
426
- info : & resource.Info {
427
- Mapping : & meta.RESTMapping {
428
- Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
472
+ infos : []* resource.Info {
473
+ {
474
+ Mapping : & meta.RESTMapping {
475
+ Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
476
+ },
477
+ Name : "name-foo" ,
478
+ Namespace : "ns-foo" ,
429
479
},
430
- Name : "name-foo" ,
431
- Namespace : "ns-foo" ,
432
480
},
433
481
fakeClient : func () * dynamicfakeclient.FakeDynamicClient {
434
482
fakeClient := dynamicfakeclient .NewSimpleDynamicClient (scheme )
@@ -461,12 +509,14 @@ func TestWaitForCondition(t *testing.T) {
461
509
},
462
510
{
463
511
name : "handles watch created" ,
464
- info : & resource.Info {
465
- Mapping : & meta.RESTMapping {
466
- Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
512
+ infos : []* resource.Info {
513
+ {
514
+ Mapping : & meta.RESTMapping {
515
+ Resource : schema.GroupVersionResource {Group : "group" , Version : "version" , Resource : "theresource" },
516
+ },
517
+ Name : "name-foo" ,
518
+ Namespace : "ns-foo" ,
467
519
},
468
- Name : "name-foo" ,
469
- Namespace : "ns-foo" ,
470
520
},
471
521
fakeClient : func () * dynamicfakeclient.FakeDynamicClient {
472
522
fakeClient := dynamicfakeclient .NewSimpleDynamicClient (scheme )
@@ -500,7 +550,7 @@ func TestWaitForCondition(t *testing.T) {
500
550
t .Run (test .name , func (t * testing.T ) {
501
551
fakeClient := test .fakeClient ()
502
552
o := & WaitOptions {
503
- ResourceFinder : genericclioptions .NewSimpleFakeResourceFinder (test .info ),
553
+ ResourceFinder : genericclioptions .NewSimpleFakeResourceFinder (test .infos ... ),
504
554
DynamicClient : fakeClient ,
505
555
Timeout : test .timeout ,
506
556
0 commit comments