Documentation ¶
Index ¶
- func IsMockbin() bool
- func Mockbin()
- func NewTestExecutor() (CmdExecutor, *Recorder)
- type CmdExecutor
- type ExecOpt
- func BaseDir(basedir string) ExecOpt
- func ExtraEnv(env []string) ExecOpt
- func FakeExitCode(exitCode int) ExecOpt
- func FakeOn(expectedArgs []string, opts ...ExecOpt) ExecOpt
- func FakeStderr(err string) ExecOpt
- func FakeStdout(out string) ExecOpt
- func Stderr(w io.Writer) ExecOpt
- func Stdout(w io.Writer) ExecOpt
- type Recorder
- type Tester
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTestExecutor ¶
func NewTestExecutor() (CmdExecutor, *Recorder)
NewTestExecutor creates a command executor for testing purpose. Two ExecOpt are added to the executor options: 1. to prefix the command args to mock the command execution using Mockbin() and 2. to record all the command executed (before they're mutated by the first option).
Types ¶
type CmdExecutor ¶
type CmdExecutor struct {
// contains filtered or unexported fields
}
func NewExecutor ¶
func NewExecutor(opts ...ExecOpt) CmdExecutor
NewExecutor creates a new CmdExecutor with the given list of ExecOpt reversed. In this way, the first opt is executed at last.
func (CmdExecutor) Run ¶
func (executor CmdExecutor) Run(name string, args ...string) error
Run creates a new exec.Cmd and applies the ExecOpt of the executor and then run the Cmd.
func (CmdExecutor) With ¶
func (executor CmdExecutor) With(opts ...ExecOpt) CmdExecutor
With returns a new CmdExecutor with the given ExecOpt prepended to the list of ExecOpt of the current executor. In this way, the options added first are executed at last.