Skip to content

Commit

Permalink
Fix and add integration test
Browse files Browse the repository at this point in the history
- Fixed error when no values are passed in
- Added integration test

Signed-off-by: Massimiliano Donini <[email protected]>
  • Loading branch information
Massimiliano Donini committed Mar 15, 2022
1 parent e3168f9 commit feb4b66
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/chart/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
20 changes: 16 additions & 4 deletions pkg/chart/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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),
}
}
Expand All @@ -51,6 +51,7 @@ func TestInstallChart(t *testing.T) {
cfg config.Configuration
chartDir string
output TestResult
extraSet string
}

cases := []testCase{
Expand All @@ -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",
Expand All @@ -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)
Expand Down Expand Up @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions pkg/tool/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit feb4b66

Please sign in to comment.