Documentation
¶
Overview ¶
Package testutils provides utility functions and types for testing terminal interactions and handling standard output in Go tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreatePTY ¶ added in v0.2.0
CreatePTY creates a pseudo-terminal pair for testing terminal interactions. The returned master and slave *os.File can be used to simulate terminal input and output in tests. The master end can be used to write input as if typed by a user, while the slave end can be used to read output from the terminal. Both files are automatically closed after the test completes.
Lovely stolen from https://github.com/engmtcdrm/go-pardon testutils package.
func CreatePTYWithSize ¶ added in v0.2.0
CreatePTYWithSize creates a pseudo-terminal pair with the specified size for testing terminal interactions. The returned master and slave *os.File can be used to simulate terminal input and output in tests that require specific terminal dimensions. Both files are automatically closed after the test completes.
Lovely stolen from https://github.com/engmtcdrm/go-pardon testutils package.
func ReadPTYOutput ¶ added in v0.2.0
ReadPTYOutput reads all available output from the provided reader until EOF is reached.
Types ¶
type EmptyReader ¶
type EmptyReader struct{}
EmptyReader is a mock reader that simulates an empty input.
func (*EmptyReader) Read ¶
func (e *EmptyReader) Read(_ []byte) (n int, err error)
Read implements the io.Reader interface for the EmptyReader type, always returning 0 bytes read and an EOF error.
type ErrorReader ¶
type ErrorReader struct{}
ErrorReader is a mock reader that simulates an error when reading.
func (*ErrorReader) Read ¶
func (e *ErrorReader) Read(_ []byte) (n int, err error)
Read implements the io.Reader interface for the ErrorReader type, always returning 0 bytes read and an unexpected EOF error.