Documentation ¶
Index ¶
- Variables
- type Cmd
- type CmdCombinedOutputExpectation
- type CmdCombinedOutputReturns
- type CmdOutputExpectation
- type CmdOutputReturns
- type CmdRunExpectation
- type CmdRunReturns
- type CmdSetDirArgs
- type CmdSetDirExpectation
- type CmdSetEnvArgs
- type CmdSetEnvExpectation
- type CmdSetStderrArgs
- type CmdSetStderrExpectation
- type CmdSetStdinArgs
- type CmdSetStdinExpectation
- type CmdSetStdoutArgs
- type CmdSetStdoutExpectation
- type CmdSetSysProcAttrArgs
- type CmdSetSysProcAttrExpectation
- type CmdStartExpectation
- type CmdStartReturns
- type CmdStderrPipeExpectation
- type CmdStderrPipeReturns
- type CmdStdoutPipeExpectation
- type CmdStdoutPipeReturns
- type CmdStopExpectation
- type CmdWaitExpectation
- type CmdWaitReturns
- type CodeExitError
- type ExitError
- type ExitErrorWrapper
- type Interface
- type InterfaceCommandArgs
- type InterfaceCommandContextArgs
- type InterfaceCommandContextExpectation
- type InterfaceCommandContextReturns
- type InterfaceCommandExpectation
- type InterfaceCommandReturns
- type InterfaceLookPathArgs
- type InterfaceLookPathExpectation
- type InterfaceLookPathReturns
- type MockCmd
- func (_m *MockCmd) ApplyCombinedOutputExpectation(e CmdCombinedOutputExpectation)
- func (_m *MockCmd) ApplyCombinedOutputExpectations(expectations []CmdCombinedOutputExpectation)
- func (_m *MockCmd) ApplyOutputExpectation(e CmdOutputExpectation)
- func (_m *MockCmd) ApplyOutputExpectations(expectations []CmdOutputExpectation)
- func (_m *MockCmd) ApplyRunExpectation(e CmdRunExpectation)
- func (_m *MockCmd) ApplyRunExpectations(expectations []CmdRunExpectation)
- func (_m *MockCmd) ApplySetDirExpectation(e CmdSetDirExpectation)
- func (_m *MockCmd) ApplySetDirExpectations(expectations []CmdSetDirExpectation)
- func (_m *MockCmd) ApplySetEnvExpectation(e CmdSetEnvExpectation)
- func (_m *MockCmd) ApplySetEnvExpectations(expectations []CmdSetEnvExpectation)
- func (_m *MockCmd) ApplySetStderrExpectation(e CmdSetStderrExpectation)
- func (_m *MockCmd) ApplySetStderrExpectations(expectations []CmdSetStderrExpectation)
- func (_m *MockCmd) ApplySetStdinExpectation(e CmdSetStdinExpectation)
- func (_m *MockCmd) ApplySetStdinExpectations(expectations []CmdSetStdinExpectation)
- func (_m *MockCmd) ApplySetStdoutExpectation(e CmdSetStdoutExpectation)
- func (_m *MockCmd) ApplySetStdoutExpectations(expectations []CmdSetStdoutExpectation)
- func (_m *MockCmd) ApplySetSysProcAttrExpectation(e CmdSetSysProcAttrExpectation)
- func (_m *MockCmd) ApplySetSysProcAttrExpectations(expectations []CmdSetSysProcAttrExpectation)
- func (_m *MockCmd) ApplyStartExpectation(e CmdStartExpectation)
- func (_m *MockCmd) ApplyStartExpectations(expectations []CmdStartExpectation)
- func (_m *MockCmd) ApplyStderrPipeExpectation(e CmdStderrPipeExpectation)
- func (_m *MockCmd) ApplyStderrPipeExpectations(expectations []CmdStderrPipeExpectation)
- func (_m *MockCmd) ApplyStdoutPipeExpectation(e CmdStdoutPipeExpectation)
- func (_m *MockCmd) ApplyStdoutPipeExpectations(expectations []CmdStdoutPipeExpectation)
- func (_m *MockCmd) ApplyStopExpectation(e CmdStopExpectation)
- func (_m *MockCmd) ApplyStopExpectations(expectations []CmdStopExpectation)
- func (_m *MockCmd) ApplyWaitExpectation(e CmdWaitExpectation)
- func (_m *MockCmd) ApplyWaitExpectations(expectations []CmdWaitExpectation)
- func (_m *MockCmd) CombinedOutput() ([]byte, error)
- func (_m *MockCmd) Output() ([]byte, error)
- func (_m *MockCmd) Run() error
- func (_m *MockCmd) SetDir(dir string)
- func (_m *MockCmd) SetEnv(env []string)
- func (_m *MockCmd) SetStderr(out io.Writer)
- func (_m *MockCmd) SetStdin(in io.Reader)
- func (_m *MockCmd) SetStdout(out io.Writer)
- func (_m *MockCmd) SetSysProcAttr(proc *syscall.SysProcAttr)
- func (_m *MockCmd) Start() error
- func (_m *MockCmd) StderrPipe() (io.ReadCloser, error)
- func (_m *MockCmd) StdoutPipe() (io.ReadCloser, error)
- func (_m *MockCmd) Stop()
- func (_m *MockCmd) Wait() error
- type MockInterface
- func (_m *MockInterface) ApplyCommandContextExpectation(e InterfaceCommandContextExpectation)
- func (_m *MockInterface) ApplyCommandContextExpectations(expectations []InterfaceCommandContextExpectation)
- func (_m *MockInterface) ApplyCommandExpectation(e InterfaceCommandExpectation)
- func (_m *MockInterface) ApplyCommandExpectations(expectations []InterfaceCommandExpectation)
- func (_m *MockInterface) ApplyLookPathExpectation(e InterfaceLookPathExpectation)
- func (_m *MockInterface) ApplyLookPathExpectations(expectations []InterfaceLookPathExpectation)
- func (_m *MockInterface) Command(cmd string, args ...string) Cmd
- func (_m *MockInterface) CommandContext(ctx context.Context, cmd string, args ...string) Cmd
- func (_m *MockInterface) LookPath(file string) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrExecutableNotFound = osexec.ErrNotFound
ErrExecutableNotFound is returned if the executable is not found.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd interface { // Run runs the command to the completion. Run() error // CombinedOutput runs the command and returns its combined standard output // and standard error. This follows the pattern of package os/exec. CombinedOutput() ([]byte, error) // Output runs the command and returns standard output, but not standard err Output() ([]byte, error) SetDir(dir string) SetStdin(in io.Reader) SetStdout(out io.Writer) SetStderr(out io.Writer) SetEnv(env []string) SetSysProcAttr(proc *syscall.SysProcAttr) // StdoutPipe and StderrPipe for getting the process' Stdout and Stderr as // Readers StdoutPipe() (io.ReadCloser, error) StderrPipe() (io.ReadCloser, error) // Start and Wait are for running a process non-blocking Start() error Wait() error // Stops the command by sending SIGTERM. It is not guaranteed the // process will stop before this function returns. If the process is not // responding, an internal timer function will send a SIGKILL to force // terminate after 10 seconds. Stop() }
Cmd is an interface that presents an API that is very similar to Cmd from os/exec. As more functionality is needed, this can grow. Since Cmd is a struct, we will have to replace fields with get/set method pairs.
type CmdCombinedOutputExpectation ¶ added in v0.0.19
type CmdCombinedOutputExpectation struct {
Returns CmdCombinedOutputReturns
}
type CmdCombinedOutputReturns ¶ added in v0.0.19
type CmdOutputExpectation ¶ added in v0.0.19
type CmdOutputExpectation struct {
Returns CmdOutputReturns
}
type CmdOutputReturns ¶ added in v0.0.19
type CmdRunExpectation ¶ added in v0.0.19
type CmdRunExpectation struct {
Returns CmdRunReturns
}
type CmdRunReturns ¶ added in v0.0.19
type CmdRunReturns struct {
Err error
}
type CmdSetDirArgs ¶ added in v0.0.19
type CmdSetDirExpectation ¶ added in v0.0.19
type CmdSetDirExpectation struct {
Args CmdSetDirArgs
}
type CmdSetEnvArgs ¶ added in v0.0.19
type CmdSetEnvExpectation ¶ added in v0.0.19
type CmdSetEnvExpectation struct {
Args CmdSetEnvArgs
}
type CmdSetStderrArgs ¶ added in v0.0.19
type CmdSetStderrExpectation ¶ added in v0.0.19
type CmdSetStderrExpectation struct {
Args CmdSetStderrArgs
}
type CmdSetStdinArgs ¶ added in v0.0.19
type CmdSetStdinExpectation ¶ added in v0.0.19
type CmdSetStdinExpectation struct {
Args CmdSetStdinArgs
}
type CmdSetStdoutArgs ¶ added in v0.0.19
type CmdSetStdoutExpectation ¶ added in v0.0.19
type CmdSetStdoutExpectation struct {
Args CmdSetStdoutArgs
}
type CmdSetSysProcAttrArgs ¶ added in v0.0.19
type CmdSetSysProcAttrArgs struct { Proc *syscall.SysProcAttr ProcAnything bool }
type CmdSetSysProcAttrExpectation ¶ added in v0.0.19
type CmdSetSysProcAttrExpectation struct {
Args CmdSetSysProcAttrArgs
}
type CmdStartExpectation ¶ added in v0.0.19
type CmdStartExpectation struct {
Returns CmdStartReturns
}
type CmdStartReturns ¶ added in v0.0.19
type CmdStartReturns struct {
Err error
}
type CmdStderrPipeExpectation ¶ added in v0.0.19
type CmdStderrPipeExpectation struct {
Returns CmdStderrPipeReturns
}
type CmdStderrPipeReturns ¶ added in v0.0.19
type CmdStderrPipeReturns struct { Output io.ReadCloser Err error }
type CmdStdoutPipeExpectation ¶ added in v0.0.19
type CmdStdoutPipeExpectation struct {
Returns CmdStdoutPipeReturns
}
type CmdStdoutPipeReturns ¶ added in v0.0.19
type CmdStdoutPipeReturns struct { Output io.ReadCloser Err error }
type CmdStopExpectation ¶ added in v0.0.19
type CmdStopExpectation struct { }
type CmdWaitExpectation ¶ added in v0.0.19
type CmdWaitExpectation struct {
Returns CmdWaitReturns
}
type CmdWaitReturns ¶ added in v0.0.19
type CmdWaitReturns struct {
Err error
}
type CodeExitError ¶
CodeExitError is an implementation of ExitError consisting of an error object and an exit code (the upper bits of os.exec.ExitStatus).
func (CodeExitError) Error ¶
func (e CodeExitError) Error() string
func (CodeExitError) ExitStatus ¶
func (e CodeExitError) ExitStatus() int
ExitStatus is for checking the error code
func (CodeExitError) Exited ¶
func (e CodeExitError) Exited() bool
Exited is to check if the process has finished
func (CodeExitError) String ¶
func (e CodeExitError) String() string
type ExitError ¶
ExitError is an interface that presents an API similar to os.ProcessState, which is what ExitError from os/exec is. This is designed to make testing a bit easier and probably loses some of the cross-platform properties of the underlying library.
type ExitErrorWrapper ¶
ExitErrorWrapper is an implementation of ExitError in terms of os/exec ExitError. Note: standard exec.ExitError is type *os.ProcessState, which already implements Exited().
func (ExitErrorWrapper) ExitStatus ¶
func (eew ExitErrorWrapper) ExitStatus() int
ExitStatus is part of the ExitError interface.
type Interface ¶
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 // CommandContext returns a Cmd instance which can be used to run a single command. // // The provided context is used to kill the process if the context becomes done // before the command completes on its own. For example, a timeout can be set in // the context. CommandContext(ctx context.Context, cmd string, args ...string) Cmd // LookPath wraps os/exec.LookPath LookPath(file string) (string, error) }
Interface is an interface that presents a subset of the os/exec API. Use this when you want to inject fakeable/mockable exec behavior.
type InterfaceCommandArgs ¶ added in v0.0.19
type InterfaceCommandContextArgs ¶ added in v0.0.19
type InterfaceCommandContextExpectation ¶ added in v0.0.19
type InterfaceCommandContextExpectation struct { Args InterfaceCommandContextArgs Returns InterfaceCommandContextReturns }
type InterfaceCommandContextReturns ¶ added in v0.0.19
type InterfaceCommandContextReturns struct {
Cmd func() Cmd
}
type InterfaceCommandExpectation ¶ added in v0.0.19
type InterfaceCommandExpectation struct { Args InterfaceCommandArgs Returns InterfaceCommandReturns }
type InterfaceCommandReturns ¶ added in v0.0.19
type InterfaceCommandReturns struct {
Cmd func() Cmd
}
type InterfaceLookPathArgs ¶ added in v0.0.19
type InterfaceLookPathExpectation ¶ added in v0.0.19
type InterfaceLookPathExpectation struct { Args InterfaceLookPathArgs Returns InterfaceLookPathReturns }
type InterfaceLookPathReturns ¶ added in v0.0.19
type MockCmd ¶ added in v0.0.19
func (*MockCmd) ApplyCombinedOutputExpectation ¶ added in v0.0.19
func (_m *MockCmd) ApplyCombinedOutputExpectation(e CmdCombinedOutputExpectation)
func (*MockCmd) ApplyCombinedOutputExpectations ¶ added in v0.0.19
func (_m *MockCmd) ApplyCombinedOutputExpectations(expectations []CmdCombinedOutputExpectation)
func (*MockCmd) ApplyOutputExpectation ¶ added in v0.0.19
func (_m *MockCmd) ApplyOutputExpectation(e CmdOutputExpectation)
func (*MockCmd) ApplyOutputExpectations ¶ added in v0.0.19
func (_m *MockCmd) ApplyOutputExpectations(expectations []CmdOutputExpectation)
func (*MockCmd) ApplyRunExpectation ¶ added in v0.0.19
func (_m *MockCmd) ApplyRunExpectation(e CmdRunExpectation)
func (*MockCmd) ApplyRunExpectations ¶ added in v0.0.19
func (_m *MockCmd) ApplyRunExpectations(expectations []CmdRunExpectation)
func (*MockCmd) ApplySetDirExpectation ¶ added in v0.0.19
func (_m *MockCmd) ApplySetDirExpectation(e CmdSetDirExpectation)
func (*MockCmd) ApplySetDirExpectations ¶ added in v0.0.19
func (_m *MockCmd) ApplySetDirExpectations(expectations []CmdSetDirExpectation)
func (*MockCmd) ApplySetEnvExpectation ¶ added in v0.0.19
func (_m *MockCmd) ApplySetEnvExpectation(e CmdSetEnvExpectation)
func (*MockCmd) ApplySetEnvExpectations ¶ added in v0.0.19
func (_m *MockCmd) ApplySetEnvExpectations(expectations []CmdSetEnvExpectation)
func (*MockCmd) ApplySetStderrExpectation ¶ added in v0.0.19
func (_m *MockCmd) ApplySetStderrExpectation(e CmdSetStderrExpectation)
func (*MockCmd) ApplySetStderrExpectations ¶ added in v0.0.19
func (_m *MockCmd) ApplySetStderrExpectations(expectations []CmdSetStderrExpectation)
func (*MockCmd) ApplySetStdinExpectation ¶ added in v0.0.19
func (_m *MockCmd) ApplySetStdinExpectation(e CmdSetStdinExpectation)
func (*MockCmd) ApplySetStdinExpectations ¶ added in v0.0.19
func (_m *MockCmd) ApplySetStdinExpectations(expectations []CmdSetStdinExpectation)
func (*MockCmd) ApplySetStdoutExpectation ¶ added in v0.0.19
func (_m *MockCmd) ApplySetStdoutExpectation(e CmdSetStdoutExpectation)
func (*MockCmd) ApplySetStdoutExpectations ¶ added in v0.0.19
func (_m *MockCmd) ApplySetStdoutExpectations(expectations []CmdSetStdoutExpectation)
func (*MockCmd) ApplySetSysProcAttrExpectation ¶ added in v0.0.19
func (_m *MockCmd) ApplySetSysProcAttrExpectation(e CmdSetSysProcAttrExpectation)
func (*MockCmd) ApplySetSysProcAttrExpectations ¶ added in v0.0.19
func (_m *MockCmd) ApplySetSysProcAttrExpectations(expectations []CmdSetSysProcAttrExpectation)
func (*MockCmd) ApplyStartExpectation ¶ added in v0.0.19
func (_m *MockCmd) ApplyStartExpectation(e CmdStartExpectation)
func (*MockCmd) ApplyStartExpectations ¶ added in v0.0.19
func (_m *MockCmd) ApplyStartExpectations(expectations []CmdStartExpectation)
func (*MockCmd) ApplyStderrPipeExpectation ¶ added in v0.0.19
func (_m *MockCmd) ApplyStderrPipeExpectation(e CmdStderrPipeExpectation)
func (*MockCmd) ApplyStderrPipeExpectations ¶ added in v0.0.19
func (_m *MockCmd) ApplyStderrPipeExpectations(expectations []CmdStderrPipeExpectation)
func (*MockCmd) ApplyStdoutPipeExpectation ¶ added in v0.0.19
func (_m *MockCmd) ApplyStdoutPipeExpectation(e CmdStdoutPipeExpectation)
func (*MockCmd) ApplyStdoutPipeExpectations ¶ added in v0.0.19
func (_m *MockCmd) ApplyStdoutPipeExpectations(expectations []CmdStdoutPipeExpectation)
func (*MockCmd) ApplyStopExpectation ¶ added in v0.0.19
func (_m *MockCmd) ApplyStopExpectation(e CmdStopExpectation)
func (*MockCmd) ApplyStopExpectations ¶ added in v0.0.19
func (_m *MockCmd) ApplyStopExpectations(expectations []CmdStopExpectation)
func (*MockCmd) ApplyWaitExpectation ¶ added in v0.0.19
func (_m *MockCmd) ApplyWaitExpectation(e CmdWaitExpectation)
func (*MockCmd) ApplyWaitExpectations ¶ added in v0.0.19
func (_m *MockCmd) ApplyWaitExpectations(expectations []CmdWaitExpectation)
func (*MockCmd) CombinedOutput ¶ added in v0.0.19
func (*MockCmd) SetSysProcAttr ¶ added in v0.0.19
func (_m *MockCmd) SetSysProcAttr(proc *syscall.SysProcAttr)
func (*MockCmd) StderrPipe ¶ added in v0.0.19
func (_m *MockCmd) StderrPipe() (io.ReadCloser, error)
StderrPipe provides a mock function with given fields:
func (*MockCmd) StdoutPipe ¶ added in v0.0.19
func (_m *MockCmd) StdoutPipe() (io.ReadCloser, error)
StdoutPipe provides a mock function with given fields:
type MockInterface ¶ added in v0.0.19
func (*MockInterface) ApplyCommandContextExpectation ¶ added in v0.0.19
func (_m *MockInterface) ApplyCommandContextExpectation(e InterfaceCommandContextExpectation)
func (*MockInterface) ApplyCommandContextExpectations ¶ added in v0.0.19
func (_m *MockInterface) ApplyCommandContextExpectations(expectations []InterfaceCommandContextExpectation)
func (*MockInterface) ApplyCommandExpectation ¶ added in v0.0.19
func (_m *MockInterface) ApplyCommandExpectation(e InterfaceCommandExpectation)
func (*MockInterface) ApplyCommandExpectations ¶ added in v0.0.19
func (_m *MockInterface) ApplyCommandExpectations(expectations []InterfaceCommandExpectation)
func (*MockInterface) ApplyLookPathExpectation ¶ added in v0.0.19
func (_m *MockInterface) ApplyLookPathExpectation(e InterfaceLookPathExpectation)
func (*MockInterface) ApplyLookPathExpectations ¶ added in v0.0.19
func (_m *MockInterface) ApplyLookPathExpectations(expectations []InterfaceLookPathExpectation)
func (*MockInterface) Command ¶ added in v0.0.19
func (_m *MockInterface) Command(cmd string, args ...string) Cmd
Command provides a mock function with given fields: cmd, args