Skip to content

Commit

Permalink
fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ktarplee committed Oct 19, 2019
1 parent dff2eed commit 84d32bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/skaffold/deploy/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (h *HelmDeployer) isHelmV3(ctx context.Context) (bool, error) {
if err := h.helm(ctx, buf, false, "version", "--short"); err != nil {
return false, errors.Wrap(err, "detecting helm version")
}
helm3 := buf.String()[:2] == "v3"
helm3 := strings.HasPrefix(buf.String(), "v3")
if helm3 {
logrus.Infof("Detected helm version 3")
} else {
Expand Down
10 changes: 10 additions & 0 deletions pkg/skaffold/deploy/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,9 @@ type MockHelm struct {

packageOut io.Reader
packageResult error

versionOut io.Reader
versionResult error
}

func (m *MockHelm) ForTest(t *testing.T) {
Expand Down Expand Up @@ -560,6 +563,13 @@ func (m *MockHelm) RunCmd(c *exec.Cmd) error {
}
}
return m.packageResult
case "version":
if m.versionOut != nil {
if _, err := io.Copy(c.Stdout, m.versionOut); err != nil {
m.t.Errorf("Failed to copy stdout")
}
}
return m.versionResult
default:
m.t.Errorf("Unknown helm command: %+v", c)
return nil
Expand Down

0 comments on commit 84d32bf

Please sign in to comment.