test

package
v0.0.0-...-e6a9d9d Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

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