pkg/util/exec: allow mocking of LookPath

This commit is contained in:
Mikaël Cluseau
2015-09-11 19:32:35 +11:00
parent 99a1cfa8ff
commit 1ab520a59b
5 changed files with 29 additions and 3 deletions

View File

@@ -27,6 +27,9 @@ type Interface interface {
// Command returns a Cmd instance which can be used to run a single command.
// This follows the pattern of package os/exec.
Command(cmd string, args ...string) Cmd
// LookPath wraps os/exec.LookPath
LookPath(file string) (string, error)
}
// Cmd is an interface that presents an API that is very similar to Cmd from os/exec.
@@ -62,6 +65,11 @@ func (executor *executor) Command(cmd string, args ...string) Cmd {
return (*cmdWrapper)(osexec.Command(cmd, args...))
}
// LookPath is part of the Interface interface
func (executor *executor) LookPath(file string) (string, error) {
return osexec.LookPath(file)
}
// Wraps exec.Cmd so we can capture errors.
type cmdWrapper osexec.Cmd