Documentation
¶
Overview ¶
Package run provides a small fluent harness for exercising a Command[[]byte, []byte] in tests: configure stdin, run, and inspect the captured output lines and error.
res := run.Command(myCmd).WithStdinLines("a", "b").Run()
// res.Stdout == []string{...}, res.Err == nil
It complements the package-level testable.Test / testable.TestLines helpers with explicit input control (custom readers, injected read errors).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct {
Stdout []string // Output lines (the command's output stream)
Err error // First error carried by the stream, if any
}
Result holds the captured output and error from a command execution.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner configures and executes a command for testing. Every With* method returns a NEW Runner, so a Runner is immutable and safe to reuse.
func WithContext ¶
WithContext (standalone) creates a Runner bound to ctx.
func (Runner) Run ¶
Run executes the configured command and returns the captured result. It is a terminal operation.
func (Runner) WithContext ¶
WithContext returns a copy of the Runner bound to ctx.
func (Runner) WithStdinError ¶
WithStdinError returns a copy of the Runner that fails the input stream with err, for exercising error propagation.
func (Runner) WithStdinLines ¶
WithStdinLines returns a copy of the Runner whose input is lines joined by newlines (each line, including the last, terminated by '\n').