From 6e5fa6fa15dae101a0a9b544a04c49db11f44f35 Mon Sep 17 00:00:00 2001 From: Dawid Rusnak Date: Fri, 22 Mar 2024 17:36:22 +0100 Subject: [PATCH] fix: unit tests: fail TestWorkflow's shell command on error (#5238) --- .../testworkflowprocessor/processor_test.go | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/pkg/tcl/testworkflowstcl/testworkflowprocessor/processor_test.go b/pkg/tcl/testworkflowstcl/testworkflowprocessor/processor_test.go index 0458da876ba..10f943bca44 100644 --- a/pkg/tcl/testworkflowstcl/testworkflowprocessor/processor_test.go +++ b/pkg/tcl/testworkflowstcl/testworkflowprocessor/processor_test.go @@ -112,7 +112,7 @@ func TestProcessBasic(t *testing.T) { "-r", fmt.Sprintf("=%s", sig[0].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -196,7 +196,7 @@ func TestProcessBasicEnvReference(t *testing.T) { "-r", fmt.Sprintf("=%s", sig[0].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{ @@ -265,7 +265,7 @@ func TestProcessMultipleSteps(t *testing.T) { "-r", fmt.Sprintf("=%s&&%s", sig[0].Ref(), sig[1].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -288,7 +288,7 @@ func TestProcessMultipleSteps(t *testing.T) { "-r", fmt.Sprintf("=%s&&%s", sig[0].Ref(), sig[1].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test-2"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test-2"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -357,7 +357,7 @@ func TestProcessNestedSteps(t *testing.T) { "-r", fmt.Sprintf("=%s&&%s&&%s", sig[0].Ref(), sig[1].Ref(), sig[2].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -380,7 +380,7 @@ func TestProcessNestedSteps(t *testing.T) { "-r", fmt.Sprintf("%s=%s&&%s", sig[1].Ref(), sig[1].Children()[0].Ref(), sig[1].Children()[1].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test-2"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test-2"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -403,7 +403,7 @@ func TestProcessNestedSteps(t *testing.T) { "-r", fmt.Sprintf("%s=%s&&%s", sig[1].Ref(), sig[1].Children()[0].Ref(), sig[1].Children()[1].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test-3"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test-3"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -426,7 +426,7 @@ func TestProcessNestedSteps(t *testing.T) { "-r", fmt.Sprintf("=%s&&%s&&%s", sig[0].Ref(), sig[1].Ref(), sig[2].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test-4"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test-4"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -495,7 +495,7 @@ func TestProcessOptionalSteps(t *testing.T) { "-r", fmt.Sprintf("=%s&&%s", sig[0].Ref(), sig[2].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -517,7 +517,7 @@ func TestProcessOptionalSteps(t *testing.T) { "-r", fmt.Sprintf("%s=%s&&%s", sig[1].Ref(), sig[1].Children()[0].Ref(), sig[1].Children()[1].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test-2"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test-2"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -539,7 +539,7 @@ func TestProcessOptionalSteps(t *testing.T) { "-r", fmt.Sprintf("%s=%s&&%s", sig[1].Ref(), sig[1].Children()[0].Ref(), sig[1].Children()[1].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test-3"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test-3"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -562,7 +562,7 @@ func TestProcessOptionalSteps(t *testing.T) { "-r", fmt.Sprintf("=%s&&%s", sig[0].Ref(), sig[2].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test-4"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test-4"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -631,7 +631,7 @@ func TestProcessNegativeSteps(t *testing.T) { "-r", fmt.Sprintf("=%s&&%s&&%s", sig[0].Ref(), sig[1].Ref(), sig[2].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -655,7 +655,7 @@ func TestProcessNegativeSteps(t *testing.T) { "-r", fmt.Sprintf("%s.v=%s&&%s", sig[1].Ref(), sig[1].Children()[0].Ref(), sig[1].Children()[1].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test-2"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test-2"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -679,7 +679,7 @@ func TestProcessNegativeSteps(t *testing.T) { "-r", fmt.Sprintf("%s.v=%s&&%s", sig[1].Ref(), sig[1].Children()[0].Ref(), sig[1].Children()[1].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test-3"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test-3"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -702,7 +702,7 @@ func TestProcessNegativeSteps(t *testing.T) { "-r", fmt.Sprintf("=%s&&%s&&%s", sig[0].Ref(), sig[1].Ref(), sig[2].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test-4"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test-4"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -764,7 +764,7 @@ func TestProcessNegativeContainerStep(t *testing.T) { "-r", fmt.Sprintf("=%s&&%s", sig[0].Ref(), sig[1].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -788,7 +788,7 @@ func TestProcessNegativeContainerStep(t *testing.T) { "-r", fmt.Sprintf("=%s&&%s", sig[0].Ref(), sig[1].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test-2"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test-2"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -851,7 +851,7 @@ func TestProcessOptionalContainerStep(t *testing.T) { "-r", fmt.Sprintf("=%s", sig[0].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -873,7 +873,7 @@ func TestProcessOptionalContainerStep(t *testing.T) { "-c", fmt.Sprintf("%s=passed", sig[1].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test-2"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test-2"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -946,7 +946,7 @@ func TestProcessLocalContent(t *testing.T) { "-r", fmt.Sprintf("=%s&&%s", sig[0].Ref(), sig[1].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -969,7 +969,7 @@ func TestProcessLocalContent(t *testing.T) { "-r", fmt.Sprintf("=%s&&%s", sig[0].Ref(), sig[1].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test-2"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test-2"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -1048,7 +1048,7 @@ func TestProcessGlobalContent(t *testing.T) { "-r", fmt.Sprintf("=%s&&%s", sig[0].Ref(), sig[1].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}}, @@ -1071,7 +1071,7 @@ func TestProcessGlobalContent(t *testing.T) { "-r", fmt.Sprintf("=%s&&%s", sig[0].Ref(), sig[1].Ref()), "--", }, - Args: []string{defaultShell, "-c", "shell-test-2"}, + Args: []string{defaultShell, "-c", "set -e\nshell-test-2"}, WorkingDir: "", EnvFrom: []corev1.EnvFromSource(nil), Env: []corev1.EnvVar{{Name: "CI", Value: "1"}},