Documentation
¶
Index ¶
- func InitFakeCmd(fake *FakeCmd, cmd string, args ...string) exec.Cmd
- type FakeAction
- type FakeCmd
- func (fake *FakeCmd) CombinedOutput() ([]byte, error)
- func (fake *FakeCmd) Output() ([]byte, error)
- func (fake *FakeCmd) Run() error
- func (fake *FakeCmd) SetDir(dir string)
- func (fake *FakeCmd) SetEnv(env []string)
- func (fake *FakeCmd) SetStderr(out io.Writer)
- func (fake *FakeCmd) SetStdin(in io.Reader)
- func (fake *FakeCmd) SetStdout(out io.Writer)
- func (fake *FakeCmd) Start() error
- func (fake *FakeCmd) StderrPipe() (io.ReadCloser, error)
- func (fake *FakeCmd) StdoutPipe() (io.ReadCloser, error)
- func (fake *FakeCmd) Stop()
- func (fake *FakeCmd) Wait() error
- type FakeCommandAction
- type FakeExec
- type FakeExitError
- type FakeStdIOPipeResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FakeCmd ¶
type FakeCmd struct {
Argv []string
CombinedOutputScript []FakeAction
CombinedOutputCalls int
CombinedOutputLog [][]string
OutputScript []FakeAction
OutputCalls int
OutputLog [][]string
RunScript []FakeAction
RunCalls int
RunLog [][]string
Dirs []string
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
Env []string
StdoutPipeResponse FakeStdIOPipeResponse
StderrPipeResponse FakeStdIOPipeResponse
WaitResponse error
StartResponse error
DisableScripts bool
}
FakeCmd is a simple scripted Cmd type.
func (*FakeCmd) CombinedOutput ¶
CombinedOutput returns the output from the command
func (*FakeCmd) Start ¶
Start mimicks starting the process (in the background) and returns the injected StartResponse
func (*FakeCmd) StderrPipe ¶
func (fake *FakeCmd) StderrPipe() (io.ReadCloser, error)
StderrPipe returns an injected ReadCloser & error (via StderrPipeResponse) to be able to inject an output stream on Stderr
func (*FakeCmd) StdoutPipe ¶
func (fake *FakeCmd) StdoutPipe() (io.ReadCloser, error)
StdoutPipe returns an injected ReadCloser & error (via StdoutPipeResponse) to be able to inject an output stream on Stdout
type FakeCommandAction ¶
FakeCommandAction is the function to be executed
type FakeExec ¶
type FakeExec struct {
CommandScript []FakeCommandAction
CommandCalls int
LookPathFunc func(string) (string, error)
// ExactOrder enforces that commands are called in the order they are scripted,
// and with the exact same arguments
ExactOrder bool
// DisableScripts removes the requirement that CommandScripts be populated
// before calling Command(). This makes Command() and subsequent calls to
// Run() or CombinedOutput() always return success and empty output.
DisableScripts bool
// contains filtered or unexported fields
}
FakeExec is a simple scripted Interface type.
func (*FakeExec) Command ¶
Command returns the next unexecuted command in CommandScripts. This function is safe for concurrent access as long as the underlying FakeExec struct is not modified during execution.
func (*FakeExec) CommandContext ¶
CommandContext wraps arguments into exec.Cmd
type FakeExitError ¶
type FakeExitError struct {
Status int
}
FakeExitError is a simple fake ExitError type.
func (FakeExitError) Error ¶
func (fake FakeExitError) Error() string
func (FakeExitError) ExitStatus ¶
func (fake FakeExitError) ExitStatus() int
ExitStatus returns the fake status
func (FakeExitError) String ¶
func (fake FakeExitError) String() string
type FakeStdIOPipeResponse ¶
type FakeStdIOPipeResponse struct {
ReadCloser io.ReadCloser
Error error
}
FakeStdIOPipeResponse holds responses to use as fakes for the StdoutPipe and StderrPipe method calls