Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer captures output into a thread-safe buffer for testing. Use this to verify command output in tests.
type ErrorInjector ¶
type ErrorInjector struct {
// contains filtered or unexported fields
}
ErrorInjector returns an error after a specified number of writes. Useful for testing error handling in output paths.
func NewErrorInjector ¶
func NewErrorInjector(wrapped OutputFunc, errorAt int, err error) *ErrorInjector
NewErrorInjector creates an OutputFunc that injects an error at a specific call.
func (*ErrorInjector) Write ¶
func (e *ErrorInjector) Write(output string) error
Write delegates to the wrapped function until the error point is reached.
type OutputFunc ¶
OutputFunc is a function type that writes output. This abstraction enables testing by allowing output to be captured or redirected without depending on concrete io.Writer implementations.
func StderrFunc ¶
func StderrFunc(w io.Writer) OutputFunc
StderrFunc creates an OutputFunc that writes to an io.Writer with newlines. Identical to StdoutFunc but semantically distinct for stderr.
func StdoutFunc ¶
func StdoutFunc(w io.Writer) OutputFunc
StdoutFunc creates an OutputFunc that writes to an io.Writer with newlines. This is the standard implementation for production use.
type Tee ¶
type Tee struct {
// contains filtered or unexported fields
}
Tee writes output to multiple OutputFuncs simultaneously. Similar to Unix tee command, useful for capturing output while still displaying it.
func NewTee ¶
func NewTee(outputs ...OutputFunc) *Tee
NewTee creates an OutputFunc that writes to multiple destinations.