Documentation
¶
Index ¶
- type Options
- type TestRunner
- func (self *TestRunner) MockBrokenCommand(name string)
- func (self *TestRunner) MockCommand(name string)
- func (self *TestRunner) MockCommitMessage(message string)
- func (self *TestRunner) MockGit(version string)
- func (self *TestRunner) MockNoCommandsInstalled()
- func (self *TestRunner) MustQuery(name string, arguments ...string) string
- func (self *TestRunner) MustQueryStringCode(fullCmd string) (output string, exitCode int)
- func (self *TestRunner) MustQueryStringCodeWith(fullCmd string, opts *Options) (output string, exitCode int)
- func (self *TestRunner) MustQueryWith(opts *Options, cmd string, args ...string) (output string)
- func (self *TestRunner) MustRun(name string, arguments ...string)
- func (self *TestRunner) Query(name string, arguments ...string) (output string, err error)
- func (self *TestRunner) QueryString(fullCmd string) (output string, err error)
- func (self *TestRunner) QueryStringWith(fullCmd string, opts *Options) (output string, err error)
- func (self *TestRunner) QueryTrim(name string, arguments ...string) (output string, err error)
- func (self *TestRunner) QueryWith(opts *Options, cmd string, args ...string) (output string, err error)
- func (self *TestRunner) QueryWithCode(opts *Options, cmd string, args ...string) (output string, exitCode int, err error)
- func (self *TestRunner) Run(name string, arguments ...string) error
- func (self *TestRunner) SetProposalOverride(content string)
- func (self *TestRunner) SetTestOrigin(content string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct { // Dir contains the directory in which to execute the command. // If empty, runs in the current directory. Dir string `exhaustruct:"optional"` // Env allows to override the environment variables to use in the subshell, in the format provided by os.Environ() // If empty, uses the environment variables of this process. Env []string `exhaustruct:"optional"` // when set, captures the output and returns it IgnoreOutput bool `exhaustruct:"optional"` // input to pipe into STDIN Input Option[string] `exhaustruct:"optional"` }
Options defines optional arguments for ShellRunner.RunWith().
type TestRunner ¶
type TestRunner struct { // the directory that contains mock executables, ignored if empty BinDir string // the directory that contains the global Git configuration HomeDir string // content of the GIT_TOWN_TEST_PROPOSAL environment variable ProposalOverride Option[string] // whether to log the output of subshell commands Verbose configdomain.Verbose // the directory in which this runner executes shell commands WorkingDir string // contains filtered or unexported fields }
TestRunner runs shell commands using a customizable environment. This is useful in tests. Possible customizations:
- overide environment variables
- Temporarily override certain shell commands with mock implementations. Temporary mocks are only valid for the next command being run.
func (*TestRunner) MockBrokenCommand ¶
func (self *TestRunner) MockBrokenCommand(name string)
MockBrokenCommand adds a mock for the given command that returns an error.
func (*TestRunner) MockCommand ¶
func (self *TestRunner) MockCommand(name string)
MockCommand adds a mock for the command with the given name.
func (*TestRunner) MockCommitMessage ¶
func (self *TestRunner) MockCommitMessage(message string)
MockCommitMessage sets up this runner with an editor that enters the given commit message.
func (*TestRunner) MockGit ¶
func (self *TestRunner) MockGit(version string)
MockGit pretends that this repo has Git in the given version installed.
func (*TestRunner) MockNoCommandsInstalled ¶
func (self *TestRunner) MockNoCommandsInstalled()
MockNoCommandsInstalled pretends that no commands are installed.
func (*TestRunner) MustQuery ¶
func (self *TestRunner) MustQuery(name string, arguments ...string) string
MustQuery provides the output of the given command with the given arguments. Overrides will be used and removed when done.
func (*TestRunner) MustQueryStringCode ¶
func (self *TestRunner) MustQueryStringCode(fullCmd string) (output string, exitCode int)
func (*TestRunner) MustQueryStringCodeWith ¶
func (self *TestRunner) MustQueryStringCodeWith(fullCmd string, opts *Options) (output string, exitCode int)
func (*TestRunner) MustQueryWith ¶
func (self *TestRunner) MustQueryWith(opts *Options, cmd string, args ...string) (output string)
MustQueryWith provides the output of the given command and didn't encounter any form of error.
func (*TestRunner) MustRun ¶
func (self *TestRunner) MustRun(name string, arguments ...string)
Run runs the given command with the given arguments. Overrides will be used and removed when done.
func (*TestRunner) Query ¶
func (self *TestRunner) Query(name string, arguments ...string) (output string, err error)
Query provides the output of the given command. Overrides will be used and removed when done.
func (*TestRunner) QueryString ¶
func (self *TestRunner) QueryString(fullCmd string) (output string, err error)
QueryString runs the given command (including possible arguments). Overrides will be used and removed when done.
func (*TestRunner) QueryStringWith ¶
func (self *TestRunner) QueryStringWith(fullCmd string, opts *Options) (output string, err error)
QueryStringWith runs the given command (including possible arguments) using the given options. opts.Dir is a relative path inside the working directory of this ShellRunner. Overrides will be used and removed when done.
func (*TestRunner) QueryTrim ¶
func (self *TestRunner) QueryTrim(name string, arguments ...string) (output string, err error)
Query provides the output of the given command. Overrides will be used and removed when done.
func (*TestRunner) QueryWith ¶
func (self *TestRunner) QueryWith(opts *Options, cmd string, args ...string) (output string, err error)
QueryWith provides the output of the given command and ensures it exited with code 0.
func (*TestRunner) QueryWithCode ¶
func (self *TestRunner) QueryWithCode(opts *Options, cmd string, args ...string) (output string, exitCode int, err error)
QueryWith runs the given command with the given options in this ShellRunner's directory.
func (*TestRunner) Run ¶
func (self *TestRunner) Run(name string, arguments ...string) error
Run runs the given command with the given arguments. Overrides will be used and removed when done.
func (*TestRunner) SetProposalOverride ¶ added in v15.3.0
func (self *TestRunner) SetProposalOverride(content string)
SetTestOrigin adds the given environment variable to subsequent runs of commands.
func (*TestRunner) SetTestOrigin ¶
func (self *TestRunner) SetTestOrigin(content string)
SetTestOrigin adds the given environment variable to subsequent runs of commands.