Documentation ¶
Overview ¶
Package mocks offers standard builders and a mockery interface for testing external interfaces.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ReadCloser ¶
type ReadCloser struct {
// contains filtered or unexported fields
}
ReadCloser is a mock implementation of io.ReadCloser that behaves based on a predefined pipeline of read results. It can also mimic reading actual content when provided.
func NewReader ¶
func NewReader() *ReadCloser
NewReader initializes and returns a new Reader without any predefined behavior.
func (*ReadCloser) Close ¶
func (r *ReadCloser) Close() error
Close closes the Reader, invoking any predefined closing behavior.
func (*ReadCloser) EOF ¶
func (r *ReadCloser) EOF() *ReadCloser
EOF appends an EOF result to the pipeline, signaling the end of the data stream.
func (*ReadCloser) OnClose ¶
func (r *ReadCloser) OnClose(err error) *ReadCloser
OnClose sets a custom error return for the Close method.
func (*ReadCloser) OnRead ¶
func (r *ReadCloser) OnRead(n int, err error) *ReadCloser
OnRead appends a predefined read result to the pipeline. The result will be used in the order added when the Reader's Read method is called.
func (*ReadCloser) Read ¶
func (r *ReadCloser) Read(p []byte) (int, error)
Read reads data based on the predefined pipeline. If actual content is provided, it will read from that content instead of the pipeline.
func (*ReadCloser) WithContent ¶
func (r *ReadCloser) WithContent(content []byte) *ReadCloser
WithContent sets the provided content for the Reader to return on its next Read. It will override any predefined pipeline.
type WriteCloser ¶
type WriteCloser struct {
// contains filtered or unexported fields
}
WriteCloser is a mock implementation of io.WriteCloser that behaves based on a predefined pipeline of write results.
func NewWriteCloser ¶
func NewWriteCloser() *WriteCloser
NewWriteCloser initializes and returns a new Writer without any predefined behavior. It can also mimic writing actual content when provided.
func (*WriteCloser) Close ¶
func (wc *WriteCloser) Close() error
Close closes the WriteCloser, invoking any predefined closing behavior.
func (*WriteCloser) OnClose ¶
func (wc *WriteCloser) OnClose(err error) *WriteCloser
OnClose sets a custom error return for the Close method.
func (*WriteCloser) OnWrite ¶
func (wc *WriteCloser) OnWrite(n int, err error) *WriteCloser
OnWrite appends a predefined write result to the pipeline. The result will be used in the order added when the Writer's Write method is called.
func (*WriteCloser) WithContent ¶
func (wc *WriteCloser) WithContent(content []byte) *WriteCloser
WithContent sets the provided content for the Writer.