Documentation ¶
Overview ¶
Package mockio provides infinite streams that can be used for testing stdin/stdout.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Readable ¶
type Readable struct {
// contains filtered or unexported fields
}
Readable is an infinite stream that satisfies io.Reader and io.Writer Reads block until something is written to the stream, which mimics stdin.
func Stdin ¶
func Stdin() *Readable
Stdin returns a Readable that can be used in place of stdin for testing.
func (*Readable) Read ¶
Read satisfies the io.Reader interface.
func (*Readable) ShouldError ¶
ShouldError sets the stream to return an error on the next read.
func (*Readable) Write ¶
Write satisfies the io.Writer interface.
type Writable ¶
type Writable struct {
// contains filtered or unexported fields
}
Writable is an infinite stream that satisfies io.Writer, and adds methods to get portions of the output written to it.
func Stdout ¶
func Stdout() *Writable
Stdout returns a Writable that can be used for making assertions against what was written to stdout.
func (*Writable) ReadNow ¶
ReadNow clears the buffer and returns its previous contents.
func (*Writable) ReadUntil ¶
ReadUntil reads up to the first occurrence of the given character, or until the timeout expires, whichever comes first.
func (*Writable) ShouldError ¶
ShouldError sets the stream to return an error on the next write.
func (*Writable) WaitForWrite ¶
WaitForWrite waits until the timeout for a write to this stream.