mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 09:41:57 +00:00
Review feedback
This commit is contained in:
@@ -5,36 +5,16 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/weaveworks/scope/common/exec"
|
||||
)
|
||||
|
||||
// Cmd is a hook for mocking
|
||||
type Cmd interface {
|
||||
StdoutPipe() (io.ReadCloser, error)
|
||||
Start() error
|
||||
Wait() error
|
||||
Process() *os.Process
|
||||
}
|
||||
|
||||
// Command is a hook for mocking
|
||||
var Command = func(name string, args ...string) Cmd {
|
||||
return &realCmd{exec.Command(name, args...)}
|
||||
}
|
||||
|
||||
type realCmd struct {
|
||||
*exec.Cmd
|
||||
}
|
||||
|
||||
func (c *realCmd) Process() *os.Process {
|
||||
return c.Cmd.Process
|
||||
}
|
||||
|
||||
type mockCmd struct {
|
||||
io.ReadCloser
|
||||
}
|
||||
|
||||
// NewMockCmdString creates a new mock Cmd which has s on its stdout pipe
|
||||
func NewMockCmdString(s string) Cmd {
|
||||
func NewMockCmdString(s string) exec.Cmd {
|
||||
return &mockCmd{
|
||||
struct {
|
||||
io.Reader
|
||||
@@ -47,7 +27,7 @@ func NewMockCmdString(s string) Cmd {
|
||||
}
|
||||
|
||||
// NewMockCmd creates a new mock Cmd with rc as its stdout pipe
|
||||
func NewMockCmd(rc io.ReadCloser) Cmd {
|
||||
func NewMockCmd(rc io.ReadCloser) exec.Cmd {
|
||||
return &mockCmd{rc}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user