From 2b151cb74910c21639b6d1d4d66477a9ebf387db Mon Sep 17 00:00:00 2001 From: Ilya Lesikov Date: Tue, 22 Mar 2022 16:23:21 +0300 Subject: [PATCH] test(kube-run): fix e2e, add --dry-run with --overrides e2e test Signed-off-by: Ilya Lesikov --- test/e2e/kube-run/kube_run_test.go | 21 +++++++++++++++++---- test/pkg/werf/project.go | 7 ++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/test/e2e/kube-run/kube_run_test.go b/test/e2e/kube-run/kube_run_test.go index 5daa6f90d6..a64e8d8559 100644 --- a/test/e2e/kube-run/kube_run_test.go +++ b/test/e2e/kube-run/kube_run_test.go @@ -25,7 +25,7 @@ var _ = Describe("kube-run", func() { Entry( "show output and succeed, running non-interactively", &werf.KubeRunOptions{ - Command: `sh -c "cat /etc/os-release"`, + Command: []string{"sh", "-c", "cat /etc/os-release"}, Image: "main", }, func(out string) { @@ -35,7 +35,7 @@ var _ = Describe("kube-run", func() { Entry( "show output and succeed, running interactively with TTY", &werf.KubeRunOptions{ - Command: `sh -c "cat /etc/os-release"`, + Command: []string{"sh", "-c", "cat /etc/os-release"}, Image: "main", CommonOptions: werf.CommonOptions{ ExtraArgs: []string{"-i", "-t"}, @@ -48,7 +48,7 @@ var _ = Describe("kube-run", func() { Entry( "show output and fail, running non-interactively", &werf.KubeRunOptions{ - Command: `sh -c "cat /etc/os-release; exit 1"`, + Command: []string{"sh", "-c", "cat /etc/os-release; exit 1"}, Image: "main", CommonOptions: werf.CommonOptions{ ShouldFail: true, @@ -61,7 +61,7 @@ var _ = Describe("kube-run", func() { Entry( "show output and fail, running interactively with TTY", &werf.KubeRunOptions{ - Command: `sh -c "cat /etc/os-release; exit 1"`, + Command: []string{"sh", "-c", "cat /etc/os-release; exit 1"}, Image: "main", CommonOptions: werf.CommonOptions{ ShouldFail: true, @@ -72,5 +72,18 @@ var _ = Describe("kube-run", func() { Expect(out).To(ContainSubstring("ID=alpine")) }, ), + Entry( + "produce expected --overrides flag, running in dry-run mode", + &werf.KubeRunOptions{ + Command: []string{"hostname"}, + Image: "main", + CommonOptions: werf.CommonOptions{ + ExtraArgs: []string{"--dry-run", "--pod=testpod", "--overrides", `{"spec": {"imagePullSecrets": [{"name": "testsecret"}], "nodeName": "testnode"}}`}, + }, + }, + func(out string) { + Expect(out).To(ContainSubstring(`{"spec":{"imagePullSecrets":[{"name":"testsecret"},{"name":"testpod"}],"nodeName":"testnode"}}`)) + }, + ), ) }) diff --git a/test/pkg/werf/project.go b/test/pkg/werf/project.go index 1e8b8dec7d..1da813fd77 100644 --- a/test/pkg/werf/project.go +++ b/test/pkg/werf/project.go @@ -37,7 +37,7 @@ type BuildWithReportOptions struct { type KubeRunOptions struct { CommonOptions - Command string + Command []string Image string } @@ -94,8 +94,9 @@ func (p *Project) KubeRun(opts *KubeRunOptions) string { args = append(args, opts.Image) } - if opts.Command != "" { - args = append(args, "--", opts.Command) + if len(opts.Command) > 0 { + args = append(args, "--") + args = append(args, opts.Command...) } return p.runCommand(runCommandOptions{Args: args, ShouldFail: opts.ShouldFail})