diff --git a/pkg/skaffold/deploy/helm_test.go b/pkg/skaffold/deploy/helm_test.go index 4a855a88933..cd402c71286 100644 --- a/pkg/skaffold/deploy/helm_test.go +++ b/pkg/skaffold/deploy/helm_test.go @@ -96,8 +96,8 @@ func TestHelmDeploy(t *testing.T) { description: "get failure should install not upgrade", cmd: &MockHelm{ t: t, - getResult: cmdOutput{"", fmt.Errorf("not found")}, - upgradeResult: cmdOutput{"", fmt.Errorf("should not have called upgrade")}, + getResult: fmt.Errorf("not found"), + upgradeResult: fmt.Errorf("should not have called upgrade"), }, deployer: NewHelmDeployer(testDeployConfig, testKubeContext), builds: testBuilds, @@ -106,7 +106,7 @@ func TestHelmDeploy(t *testing.T) { description: "get success should upgrade not install", cmd: &MockHelm{ t: t, - installResult: cmdOutput{"", fmt.Errorf("should not have called install")}, + installResult: fmt.Errorf("should not have called install"), }, deployer: NewHelmDeployer(testDeployConfig, testKubeContext), builds: testBuilds, @@ -115,7 +115,7 @@ func TestHelmDeploy(t *testing.T) { description: "deploy error", cmd: &MockHelm{ t: t, - upgradeResult: cmdOutput{"", fmt.Errorf("unexpected error")}, + upgradeResult: fmt.Errorf("unexpected error"), }, shouldErr: true, deployer: NewHelmDeployer(testDeployConfig, testKubeContext), @@ -125,7 +125,7 @@ func TestHelmDeploy(t *testing.T) { description: "dep build error", cmd: &MockHelm{ t: t, - depResult: cmdOutput{"", fmt.Errorf("unexpected error")}, + depResult: fmt.Errorf("unexpected error"), }, shouldErr: true, deployer: NewHelmDeployer(testDeployConfig, testKubeContext), @@ -145,24 +145,20 @@ func TestHelmDeploy(t *testing.T) { } type MockHelm struct { - getResult cmdOutput - installResult cmdOutput - upgradeResult cmdOutput - depResult cmdOutput - t *testing.T -} -type cmdOutput struct { - stdout string - err error + getResult error + installResult error + upgradeResult error + depResult error } -func (c cmdOutput) out() ([]byte, error) { - return []byte(c.stdout), c.err +func (m *MockHelm) RunCmdOut(c *exec.Cmd) ([]byte, error) { + m.t.Error("Shouldn't be used") + return nil, nil } -func (m *MockHelm) RunCmdOut(c *exec.Cmd) ([]byte, error) { +func (m *MockHelm) RunCmd(c *exec.Cmd) error { if len(c.Args) < 3 { m.t.Errorf("Not enough args in command %v", c) } @@ -173,20 +169,15 @@ func (m *MockHelm) RunCmdOut(c *exec.Cmd) ([]byte, error) { switch c.Args[3] { case "get": - return m.getResult.out() + return m.getResult case "install": - return m.installResult.out() + return m.installResult case "upgrade": - return m.upgradeResult.out() + return m.upgradeResult case "dep": - return m.depResult.out() + return m.depResult + default: + m.t.Errorf("Unknown helm command: %+v", c) + return nil } - - m.t.Errorf("Unknown helm command: %+v", c) - return nil, nil -} - -func (m *MockHelm) RunCmd(c *exec.Cmd) error { - _, err := m.RunCmdOut(c) - return err }