@@ -290,7 +290,13 @@ func TestCreateItem(t *testing.T) {
290
290
},
291
291
mockSetup : func (runtimeClientMock * mocks.MockWithWatch ) {
292
292
runtimeClientMock .EXPECT ().
293
- Create (mock .Anything , mock .AnythingOfType ("*unstructured.Unstructured" )).
293
+ Create (
294
+ mock .Anything ,
295
+ mock .AnythingOfType ("*unstructured.Unstructured" ),
296
+ mock .MatchedBy (func (opts client.CreateOption ) bool {
297
+ return true
298
+ }),
299
+ ).
294
300
Return (nil )
295
301
},
296
302
expectedObj : map [string ]interface {}{
@@ -315,7 +321,13 @@ func TestCreateItem(t *testing.T) {
315
321
},
316
322
mockSetup : func (runtimeClientMock * mocks.MockWithWatch ) {
317
323
runtimeClientMock .EXPECT ().
318
- Create (mock .Anything , mock .AnythingOfType ("*unstructured.Unstructured" )).
324
+ Create (
325
+ mock .Anything ,
326
+ mock .AnythingOfType ("*unstructured.Unstructured" ),
327
+ mock .MatchedBy (func (opts client.CreateOption ) bool {
328
+ return true
329
+ }),
330
+ ).
319
331
Return (assert .AnError )
320
332
},
321
333
expectError : true ,
@@ -328,6 +340,35 @@ func TestCreateItem(t *testing.T) {
328
340
},
329
341
expectError : true ,
330
342
},
343
+ {
344
+ name : "create_item_with_dry_run_OK" ,
345
+ args : map [string ]interface {}{
346
+ resolver .NameArg : "test-object" ,
347
+ resolver .NamespaceArg : "test-namespace" ,
348
+ resolver .DryRunArg : []interface {}{"All" },
349
+ "object" : map [string ]interface {}{
350
+ "metadata" : map [string ]interface {}{
351
+ "name" : "test-object" ,
352
+ },
353
+ },
354
+ },
355
+ mockSetup : func (runtimeClientMock * mocks.MockWithWatch ) {
356
+ runtimeClientMock .EXPECT ().
357
+ Create (mock .Anything , mock .AnythingOfType ("*unstructured.Unstructured" ), mock .MatchedBy (func (opts client.CreateOption ) bool {
358
+ createOpts , ok := opts .(* client.CreateOptions )
359
+ return ok && len (createOpts .DryRun ) == 1 && createOpts .DryRun [0 ] == "All"
360
+ })).
361
+ Return (nil )
362
+ },
363
+ expectedObj : map [string ]interface {}{
364
+ "apiVersion" : "group/version" ,
365
+ "kind" : "kind" ,
366
+ "metadata" : map [string ]interface {}{
367
+ "name" : "test-object" ,
368
+ "namespace" : "test-namespace" ,
369
+ },
370
+ },
371
+ },
331
372
}
332
373
333
374
for _ , tt := range tests {
0 commit comments