Documentation ¶
Index ¶
- type Commands
- type ExecuteOption
- type File
- type Result
- func (r Result) RequireFailure(t *testing.T) Result
- func (r Result) RequireFiles(t *testing.T, files ...File) Result
- func (r Result) RequireLocalFiles(t *testing.T, files ...File) Result
- func (r Result) RequirePending(t *testing.T, files ...File) Result
- func (r Result) RequireRemoteFiles(t *testing.T, files ...File) Result
- func (r Result) RequireStderr(t *testing.T, stderr string) Result
- func (r Result) RequireStdout(t *testing.T, stdout string) Result
- func (r Result) RequireSuccess(t *testing.T)
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commands ¶ added in v1.34.1
Commands is an alias to refer to a function that builds clingy commands.
type ExecuteOption ¶
type ExecuteOption struct {
// contains filtered or unexported fields
}
ExecuteOption allows one to control the environment that a command executes in.
func WithFile ¶
func WithFile(location string, contents ...string) ExecuteOption
WithFile sets the command to execute with a file created at the given location.
func WithFilesystem ¶
func WithFilesystem(cb func(t *testing.T, ctx clingy.Context, fs ulfs.Filesystem)) ExecuteOption
WithFilesystem lets one do arbitrary setup on the filesystem in a callback.
func WithPendingFile ¶
func WithPendingFile(location string) ExecuteOption
WithPendingFile sets the command to execute with a pending upload happening to the provided location.
func WithStdin ¶
func WithStdin(stdin string) ExecuteOption
WithStdin sets the command to execute with the provided string as standard input.
type Result ¶
Result captures all the output of running a command for inspection.
func (Result) RequireFailure ¶
RequireFailure fails if the Result did not observe a failed execution.
func (Result) RequireFiles ¶
RequireFiles requires that the set of files provided are all of the files that existed at the end of the execution. It assumes any passed in files with no contents contain the filename as the contents instead.
func (Result) RequireLocalFiles ¶ added in v1.37.1
RequireLocalFiles requires that the set of files provided are all of the local files that existed at the end of the execution. It assumes any passed in files with no contents contain the filename as the contents instead.
func (Result) RequirePending ¶ added in v1.42.2
RequirePending requires that the set of files provided are all of the files that existed as pending at the end of the execution.
func (Result) RequireRemoteFiles ¶ added in v1.37.1
RequireRemoteFiles requires that the set of files provided are all of the remote files that existed at the end of the execution. It assumes any passed in files with no contents contain the filename as the contents instead.
func (Result) RequireStderr ¶
RequireStderr requires that the execution wrote to stderr the provided string. Blank lines are ignored and all lines are space trimmed for the comparison.
func (Result) RequireStdout ¶
RequireStdout requires that the execution wrote to stdout the provided string. Blank lines are ignored and all lines are space trimmed for the comparison.
func (Result) RequireSuccess ¶
RequireSuccess fails if the Result did not observe a successful execution.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State represents some state and environment for a command to execute in.
func Setup ¶
func Setup(cmds Commands, opts ...ExecuteOption) State
Setup returns some State that can be run multiple times with different command line arguments.
func (State) With ¶
func (st State) With(opts ...ExecuteOption) State
With appends the provided options and returns a new State.