Skip to content

Commit 7ddba87

Browse files
committed
fix: no-push=true flags with test codes fixed
1 parent 24be061 commit 7ddba87

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

pkg/skaffold/build/gcb/kaniko_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,11 +469,15 @@ func TestKanikoBuildSpec(t *testing.T) {
469469
})
470470

471471
defaultExpectedArgs := []string{
472-
"--destination", "gcr.io/nginx",
473472
"--dockerfile", "Dockerfile",
474473
}
475474

476475
for _, test := range tests {
476+
expected := append([]string{}, defaultExpectedArgs...)
477+
if !test.artifact.NoPush {
478+
expected = append(expected, "--destination", "gcr.io/nginx")
479+
}
480+
477481
testutil.Run(t, test.description, func(t *testutil.T) {
478482
artifact := &latest.Artifact{
479483
ImageName: "img1",
@@ -510,7 +514,7 @@ func TestKanikoBuildSpec(t *testing.T) {
510514
},
511515
Steps: []*cloudbuild.BuildStep{{
512516
Name: "gcr.io/kaniko-project/executor",
513-
Args: append(append(defaultExpectedArgs, imageArgs...), test.expectedArgs...),
517+
Args: append(append(expected, imageArgs...), test.expectedArgs...),
514518
Env: test.expectedEnv,
515519
}},
516520
Options: &cloudbuild.BuildOptions{

pkg/skaffold/build/kaniko/args_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ func TestArgs(t *testing.T) {
438438
}
439439

440440
defaultExpectedArgs := []string{
441-
"--destination", "gcr.io/nginx",
442441
"--dockerfile", "dir/Dockerfile",
443442
"--context", fmt.Sprintf("dir://%s", DefaultEmptyDirMountPath),
444443
}
@@ -450,7 +449,11 @@ func TestArgs(t *testing.T) {
450449
t.Errorf("Args() error = %v, wantErr %v", err, test.wantErr)
451450
return
452451
}
453-
t.CheckDeepEqual(got, append(defaultExpectedArgs, test.expectedArgs...))
452+
if test.artifact.NoPush {
453+
t.CheckDeepEqual(got, append(defaultExpectedArgs, test.expectedArgs...))
454+
} else {
455+
t.CheckDeepEqual(got, append(defaultExpectedArgs, "--destination", "gcr.io/nginx", test.expectedArgs...))
456+
}
454457
})
455458
}
456459
}

0 commit comments

Comments
 (0)