Skip to content

Commit

Permalink
test(kube-run): fix e2e, add --dry-run with --overrides e2e test
Browse files Browse the repository at this point in the history
Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
  • Loading branch information
ilya-lesikov committed Mar 22, 2022
1 parent d94104f commit 2b151cb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
21 changes: 17 additions & 4 deletions test/e2e/kube-run/kube_run_test.go
Expand Up @@ -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) {
Expand All @@ -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"},
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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"}}`))
},
),
)
})
7 changes: 4 additions & 3 deletions test/pkg/werf/project.go
Expand Up @@ -37,7 +37,7 @@ type BuildWithReportOptions struct {

type KubeRunOptions struct {
CommonOptions
Command string
Command []string
Image string
}

Expand Down Expand Up @@ -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})
Expand Down

0 comments on commit 2b151cb

Please sign in to comment.