mock

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReadWriterMock

type ReadWriterMock struct {
	// ReadAllFunc mocks the ReadAll method.
	ReadAllFunc func() ([]byte, error)

	// WriteAllFunc mocks the WriteAll method.
	WriteAllFunc func(bytes []byte) error
	// contains filtered or unexported fields
}

ReadWriterMock is a mock implementation of vald.ReadWriter.

func TestSomethingThatUsesReadWriter(t *testing.T) {

	// make and configure a mocked vald.ReadWriter
	mockedReadWriter := &ReadWriterMock{
		ReadAllFunc: func() ([]byte, error) {
			panic("mock out the ReadAll method")
		},
		WriteAllFunc: func(bytes []byte) error {
			panic("mock out the WriteAll method")
		},
	}

	// use mockedReadWriter in code that requires vald.ReadWriter
	// and then make assertions.

}

func (*ReadWriterMock) ReadAll

func (mock *ReadWriterMock) ReadAll() ([]byte, error)

ReadAll calls ReadAllFunc.

func (*ReadWriterMock) ReadAllCalls

func (mock *ReadWriterMock) ReadAllCalls() []struct {
}

ReadAllCalls gets all the calls that were made to ReadAll. Check the length with:

len(mockedReadWriter.ReadAllCalls())

func (*ReadWriterMock) WriteAll

func (mock *ReadWriterMock) WriteAll(bytes []byte) error

WriteAll calls WriteAllFunc.

func (*ReadWriterMock) WriteAllCalls

func (mock *ReadWriterMock) WriteAllCalls() []struct {
	Bytes []byte
}

WriteAllCalls gets all the calls that were made to WriteAll. Check the length with:

len(mockedReadWriter.WriteAllCalls())

Jump to

Keyboard shortcuts

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