diff --git a/internal/run/cmd.go b/internal/run/cmd.go index 9344666..dbec358 100644 --- a/internal/run/cmd.go +++ b/internal/run/cmd.go @@ -41,6 +41,10 @@ type execCmd struct { *exec.Cmd } +var Command = func() cmd { + return &execCmd{} +} + func (c *execCmd) Path(p string) { c.Cmd.Path = p } func (c *execCmd) Args(a []string) { c.Cmd.Args = a } func (c *execCmd) Env(e []string) { c.Cmd.Env = e } diff --git a/internal/run/install.go b/internal/run/install.go index 2a2092a..cdab5ce 100644 --- a/internal/run/install.go +++ b/internal/run/install.go @@ -5,13 +5,9 @@ import () const HELM_BIN = "/usr/bin/helm" func Install(args ...string) error { - cmd := &execCmd{} + cmd := Command() cmd.Path(HELM_BIN) - return install(cmd, args) -} - -func install(cmd cmd, args []string) error { args = append([]string{"install"}, args...) cmd.Args(args) diff --git a/internal/run/install_test.go b/internal/run/install_test.go index 64adc9c..4609c8f 100644 --- a/internal/run/install_test.go +++ b/internal/run/install_test.go @@ -9,12 +9,18 @@ func TestInstall(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() - cmd := NewMockcmd(ctrl) - cmd.EXPECT(). + mCmd := NewMockcmd(ctrl) + originalCommand := Command + Command = func() cmd { return mCmd } + defer func() { Command = originalCommand }() + + mCmd.EXPECT(). + Path(HELM_BIN) + mCmd.EXPECT(). Args(gomock.Eq([]string{"install", "arg1", "arg2"})) - cmd.EXPECT(). + mCmd.EXPECT(). Run(). Times(1) - install(cmd, []string{"arg1", "arg2"}) + Install("arg1", "arg2") }