From feb4b669ff92e8b43995a87fceeceb23ee16f585 Mon Sep 17 00:00:00 2001 From: Massimiliano Donini Date: Tue, 15 Mar 2022 16:06:05 +0100 Subject: [PATCH] Fix and add integration test - Fixed error when no values are passed in - Added integration test Signed-off-by: Massimiliano Donini --- pkg/chart/chart.go | 2 +- pkg/chart/integration_test.go | 20 ++++++++++++++++---- pkg/tool/helm.go | 4 ++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go index 123d934d..3d92647f 100644 --- a/pkg/chart/chart.go +++ b/pkg/chart/chart.go @@ -258,7 +258,7 @@ func NewTesting(config config.Configuration, extraSetArgs string) (Testing, erro testing := Testing{ config: config, - helm: tool.NewHelm(procExec, extraArgs, extraSetArgs), + helm: tool.NewHelm(procExec, extraArgs, strings.Fields(extraSetArgs)), git: tool.NewGit(procExec), kubectl: tool.NewKubectl(procExec), linter: tool.NewLinter(procExec), diff --git a/pkg/chart/integration_test.go b/pkg/chart/integration_test.go index 0132963e..c3b24221 100644 --- a/pkg/chart/integration_test.go +++ b/pkg/chart/integration_test.go @@ -29,7 +29,7 @@ import ( "github.com/stretchr/testify/assert" ) -func newTestingHelmIntegration(cfg config.Configuration) Testing { +func newTestingHelmIntegration(cfg config.Configuration, extraSetArgs string) Testing { fakeMockLinter := new(fakeLinter) procExec := exec.NewProcessExecutor(true) extraArgs := strings.Fields(cfg.HelmExtraArgs) @@ -40,7 +40,7 @@ func newTestingHelmIntegration(cfg config.Configuration) Testing { chartUtils: util.ChartUtils{}, accountValidator: fakeAccountValidator{}, linter: fakeMockLinter, - helm: tool.NewHelm(procExec, extraArgs), + helm: tool.NewHelm(procExec, extraArgs, strings.Fields(extraSetArgs)), kubectl: tool.NewKubectl(procExec), } } @@ -51,6 +51,7 @@ func TestInstallChart(t *testing.T) { cfg config.Configuration chartDir string output TestResult + extraSet string } cases := []testCase{ @@ -63,6 +64,7 @@ func TestInstallChart(t *testing.T) { }, "test_charts/must-pass-upgrade-install", TestResult{mustNewChart("test_charts/must-pass-upgrade-install"), nil}, + "", }, { "install only in random namespace", @@ -71,12 +73,22 @@ func TestInstallChart(t *testing.T) { }, "test_charts/must-pass-upgrade-install", TestResult{mustNewChart("test_charts/must-pass-upgrade-install"), nil}, + "", + }, + { + "install with override set", + config.Configuration{ + Debug: true, + }, + "test_charts/must-pass-upgrade-install", + TestResult{mustNewChart("test_charts/must-pass-upgrade-install"), nil}, + "--set=image.tag=latest", }, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { - ct := newTestingHelmIntegration(tc.cfg) + ct := newTestingHelmIntegration(tc.cfg, tc.extraSet) namespace := tc.cfg.Namespace if namespace != "" { ct.kubectl.CreateNamespace(namespace) @@ -107,7 +119,7 @@ func TestUpgradeChart(t *testing.T) { Debug: true, Upgrade: true, } - ct := newTestingHelmIntegration(cfg) + ct := newTestingHelmIntegration(cfg, "") processError := fmt.Errorf("Error waiting for process: exit status 1") cases := []testCase{ diff --git a/pkg/tool/helm.go b/pkg/tool/helm.go index 9e891760..bef2454f 100644 --- a/pkg/tool/helm.go +++ b/pkg/tool/helm.go @@ -23,10 +23,10 @@ import ( type Helm struct { exec exec.ProcessExecutor extraArgs []string - extraSetArgs string + extraSetArgs []string } -func NewHelm(exec exec.ProcessExecutor, extraArgs []string, extraSetArgs string) Helm { +func NewHelm(exec exec.ProcessExecutor, extraArgs []string, extraSetArgs []string) Helm { return Helm{ exec: exec, extraArgs: extraArgs,