@@ -328,3 +328,68 @@ func TestDependenciesForKustomization(t *testing.T) {
328
328
})
329
329
}
330
330
}
331
+
332
+ func TestKustomizeBuildCommandArgs (t * testing.T ) {
333
+ tests := []struct {
334
+ description string
335
+ buildArgs []string
336
+ kustomizePath string
337
+ expectedArgs []string
338
+ }{
339
+ {
340
+ description : "no BuildArgs, empty KustomizePath " ,
341
+ buildArgs : []string {},
342
+ kustomizePath : "" ,
343
+ expectedArgs : []string {"build" },
344
+ },
345
+ {
346
+ description : "One BuildArg, empty KustomizePath" ,
347
+ buildArgs : []string {"--foo" },
348
+ kustomizePath : "" ,
349
+ expectedArgs : []string {"build" , "--foo" },
350
+ },
351
+ {
352
+ description : "no BuildArgs, non-empty KustomizePath" ,
353
+ buildArgs : []string {},
354
+ kustomizePath : "foo" ,
355
+ expectedArgs : []string {"build" , "foo" },
356
+ },
357
+ {
358
+ description : "One BuildArg, non-empty KustomizePath" ,
359
+ buildArgs : []string {"--foo" },
360
+ kustomizePath : "bar" ,
361
+ expectedArgs : []string {"build" , "--foo" , "bar" },
362
+ },
363
+ {
364
+ description : "Multiple BuildArg, empty KustomizePath" ,
365
+ buildArgs : []string {"--foo" , "--bar" },
366
+ kustomizePath : "" ,
367
+ expectedArgs : []string {"build" , "--foo" , "--bar" },
368
+ },
369
+ {
370
+ description : "Multiple BuildArg with spaces, empty KustomizePath" ,
371
+ buildArgs : []string {"--foo bar" , "--baz" },
372
+ kustomizePath : "" ,
373
+ expectedArgs : []string {"build" , "--foo" , "bar" , "--baz" },
374
+ },
375
+ {
376
+ description : "Multiple BuildArg with spaces, non-empty KustomizePath" ,
377
+ buildArgs : []string {"--foo bar" , "--baz" },
378
+ kustomizePath : "barfoo" ,
379
+ expectedArgs : []string {"build" , "--foo" , "bar" , "--baz" , "barfoo" },
380
+ },
381
+ {
382
+ description : "Multiple BuildArg no spaces, non-empty KustomizePath" ,
383
+ buildArgs : []string {"--foo" , "bar" , "--baz" },
384
+ kustomizePath : "barfoo" ,
385
+ expectedArgs : []string {"build" , "--foo" , "bar" , "--baz" , "barfoo" },
386
+ },
387
+ }
388
+
389
+ for _ , test := range tests {
390
+ testutil .Run (t , test .description , func (t * testutil.T ) {
391
+ args := buildCommandArgs (test .buildArgs , test .kustomizePath )
392
+ t .CheckDeepEqual (test .expectedArgs , args )
393
+ })
394
+ }
395
+ }
0 commit comments