Skip to content

Commit 3d30428

Browse files
author
Massimiliano Donini
committed
Fix and add integration test
- Fixed error when no values are passed in - Added integration test Signed-off-by: Massimiliano Donini <[email protected]>
1 parent d1c428a commit 3d30428

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

pkg/chart/chart.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func NewTesting(config config.Configuration, extraSetArgs string) (Testing, erro
258258

259259
testing := Testing{
260260
config: config,
261-
helm: tool.NewHelm(procExec, extraArgs, extraSetArgs),
261+
helm: tool.NewHelm(procExec, extraArgs, strings.Fields(extraSetArgs)),
262262
git: tool.NewGit(procExec),
263263
kubectl: tool.NewKubectl(procExec),
264264
linter: tool.NewLinter(procExec),

pkg/chart/integration_test.go

+16-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"github.com/stretchr/testify/assert"
3030
)
3131

32-
func newTestingHelmIntegration(cfg config.Configuration) Testing {
32+
func newTestingHelmIntegration(cfg config.Configuration, extraSetArgs string) Testing {
3333
fakeMockLinter := new(fakeLinter)
3434
procExec := exec.NewProcessExecutor(true)
3535
extraArgs := strings.Fields(cfg.HelmExtraArgs)
@@ -40,7 +40,7 @@ func newTestingHelmIntegration(cfg config.Configuration) Testing {
4040
chartUtils: util.ChartUtils{},
4141
accountValidator: fakeAccountValidator{},
4242
linter: fakeMockLinter,
43-
helm: tool.NewHelm(procExec, extraArgs),
43+
helm: tool.NewHelm(procExec, extraArgs, strings.Fields(extraSetArgs)),
4444
kubectl: tool.NewKubectl(procExec),
4545
}
4646
}
@@ -51,6 +51,7 @@ func TestInstallChart(t *testing.T) {
5151
cfg config.Configuration
5252
chartDir string
5353
output TestResult
54+
extraSet string
5455
}
5556

5657
cases := []testCase{
@@ -63,6 +64,7 @@ func TestInstallChart(t *testing.T) {
6364
},
6465
"test_charts/must-pass-upgrade-install",
6566
TestResult{mustNewChart("test_charts/must-pass-upgrade-install"), nil},
67+
"",
6668
},
6769
{
6870
"install only in random namespace",
@@ -71,12 +73,22 @@ func TestInstallChart(t *testing.T) {
7173
},
7274
"test_charts/must-pass-upgrade-install",
7375
TestResult{mustNewChart("test_charts/must-pass-upgrade-install"), nil},
76+
"",
77+
},
78+
{
79+
"install with override set",
80+
config.Configuration{
81+
Debug: true,
82+
},
83+
"test_charts/must-pass-upgrade-install",
84+
TestResult{mustNewChart("test_charts/must-pass-upgrade-install"), nil},
85+
"--set=image.tag=latest",
7486
},
7587
}
7688

7789
for _, tc := range cases {
7890
t.Run(tc.name, func(t *testing.T) {
79-
ct := newTestingHelmIntegration(tc.cfg)
91+
ct := newTestingHelmIntegration(tc.cfg, tc.extraSet)
8092
namespace := tc.cfg.Namespace
8193
if namespace != "" {
8294
ct.kubectl.CreateNamespace(namespace)
@@ -107,7 +119,7 @@ func TestUpgradeChart(t *testing.T) {
107119
Debug: true,
108120
Upgrade: true,
109121
}
110-
ct := newTestingHelmIntegration(cfg)
122+
ct := newTestingHelmIntegration(cfg, "")
111123
processError := fmt.Errorf("Error waiting for process: exit status 1")
112124

113125
cases := []testCase{

pkg/tool/helm.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import (
2323
type Helm struct {
2424
exec exec.ProcessExecutor
2525
extraArgs []string
26-
extraSetArgs string
26+
extraSetArgs []string
2727
}
2828

29-
func NewHelm(exec exec.ProcessExecutor, extraArgs []string, extraSetArgs string) Helm {
29+
func NewHelm(exec exec.ProcessExecutor, extraArgs []string, extraSetArgs []string) Helm {
3030
return Helm{
3131
exec: exec,
3232
extraArgs: extraArgs,

0 commit comments

Comments
 (0)