test

package
v0.0.0-...-b4eb1e2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockReadCloser

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

MockReadCloser implements reading from a predefined byte slice and tracks closed state for testing.

func NewMockReadCloser

func NewMockReadCloser(t *testing.T, data []byte) *MockReadCloser

NewMockReadCloser constructs a ReadCloser bound to the given test and byte slice.

func (*MockReadCloser) Close

func (mrc *MockReadCloser) Close() error

Close tracks closed state and returns nil.

func (*MockReadCloser) IsClosed

func (mrc *MockReadCloser) IsClosed() bool

IsClosed allows test code to query whether or not a MockReadCloser has been closed.

func (*MockReadCloser) Read

func (mrc *MockReadCloser) Read(p []byte) (n int, err error)

Read ensures that MockReadCloser has not be closed, then delegates to a reader that wraps a predefined byte slice.

type MockWriteCloser

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

MockWriteCloser tracks write+close state for testing purposes.

func NewMockWriteCloser

func NewMockWriteCloser(t *testing.T) *MockWriteCloser

NewMockWriteCloser constructs a MockWriteCloser for a given test.

func (*MockWriteCloser) Close

func (mwc *MockWriteCloser) Close() error

Close stores "closed" state and synchronizes by sending true to MockWriteCloser.c iff it is not nil. Note that the synchronization message is sent from this goroutine; i.e., Close() will not return until another goroutine receives the message.

func (*MockWriteCloser) Write

func (mwc *MockWriteCloser) Write(p []byte) (n int, err error)

Write ensures MockWriteCloser isn't closed and delegates to an underlying buffer for writing.

Jump to

Keyboard shortcuts

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