scenario

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder constructs test scenarios fluently.

func New

func New() *Builder

New creates a new test scenario builder.

func (*Builder) Build

func (b *Builder) Build() *Test

Build constructs the final Test scenario.

func (*Builder) WithInput

func (b *Builder) WithInput(lines ...string) *Builder

WithInput sets the input source for the test.

func (*Builder) WithInputError

func (b *Builder) WithInputError(afterLines int, err error) *Builder

WithInputError injects a read error after reading N lines.

func (*Builder) WithInputReader

func (b *Builder) WithInputReader(reader stream.LineReader) *Builder

WithInputReader sets a custom input reader.

func (*Builder) WithOutputError

func (b *Builder) WithOutputError(afterWrites int, err error) *Builder

WithOutputError injects a write error on stdout after N writes.

func (*Builder) WithStderrError

func (b *Builder) WithStderrError(afterWrites int, err error) *Builder

WithStderrError injects a write error on stderr after N writes.

type Test

type Test struct {
	Input  stream.LineReader
	Stdout capture.OutputFunc
	Stderr capture.OutputFunc

	// Captured outputs for verification
	StdoutBuffer *capture.Buffer
	StderrBuffer *capture.Buffer
}

Test represents a complete test scenario with input, output, and error handling. Use Builder to construct test scenarios fluently.

func Empty

func Empty() *Test

Empty creates a test scenario with no input.

func Quick

func Quick(input ...string) *Test

Quick creates a simple test scenario with the given input lines. Most common use case - just provide input and capture output.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL