Documentation ¶
Overview ¶
Package testecho assists execution of the CLI from test cases and assertion of its result.
Its provides some default inputs for the CLI to support use cases where details such as the exact standard output/error are asserted for equality but semantic content is unnecessary.
Index ¶
Constants ¶
const ( // DefaultStdout is the default value for the --stdout flag. DefaultStdout = "some stdout message" // DefaultStdoutFromStdin is the standard output emitted by testecho when it receives DefaultStdout via // standard input. // // It supports the "testecho | testecho" use case and asserting the final process's behavior. DefaultStdoutFromStdin = "stdin [" + DefaultStdout + "]" // DefaultStderr is the default value for the --stderr flag. DefaultStderr = "some stderr message" // DefaultStdoutFromStdinNested is the standard output emitted by testecho when it receives // DefaultStdoutFromStdin via standard input. // // It supports the "testecho | testecho | testecho" use case and asserting the final process's behavior. DefaultStdoutFromStdinNested = "stdin [" + DefaultStdoutFromStdin + "]" )
Variables ¶
This section is empty.
Functions ¶
func NewCmd ¶
NewCmd converts an Input into a command.
It no Input is passed, a zero-valued Input is used. If one Input is passed, it is converted. If multiple Input values are passed, it panics.
func NewCmdArgs ¶
NewCmdArgs converts an Input value into argument strings for use in exec.Command.
It no Input is passed, a zero-valued Input is used. If one Input is passed, it is converted. If multiple Input values are passed, it panics.
Types ¶
type Input ¶
type Input struct { // Code is the value for the --code flag. Code int // Stderr is a value for the --sleep flag. Sleep int // Spawn is true if the command should spawn a child process and block forever (because the child does). Spawn bool // Stdin is true if the command is expected to receive stdin. Stdin bool // Stderr is a value for the --stderr flag. // // If empty, DefaultStderr is used. Stderr string // Stderr is a value for the --stdout flag. // // If empty, DefaultStdout is used. Stdout string }
Input defines the CLI flags to use in a testecho invocation.