The recommended way to test code that uses exec.Cmd involves setting up a real exec.Cmd that invokes `go test` with additional arguments that fire off a specially-constructed test that behaves the way the mocked- out script would be expected to do. It's a sensible way to test exec.Cmd itself, but for code that merely invokes it, I think it makes more sense to use actual mocks.
20 lines
292 B
Go
20 lines
292 B
Go
package run
|
|
|
|
import ()
|
|
|
|
const HELM_BIN = "/usr/bin/helm"
|
|
|
|
func Install(args ...string) error {
|
|
cmd := &execCmd{}
|
|
cmd.Path(HELM_BIN)
|
|
|
|
return install(cmd, args)
|
|
}
|
|
|
|
func install(cmd cmd, args []string) error {
|
|
args = append([]string{"install"}, args...)
|
|
cmd.Args(args)
|
|
|
|
return cmd.Run()
|
|
}
|