mock

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockAddr

type MockAddr struct {
	Ntwrk string // name of the network (for example, "tcp", "udp")
	Str   string // string form of address (for example, "192.0.2.1:25", "[2001:db8::1]:80")
}

MockAddr mocks net.Addr

func (*MockAddr) Network

func (m *MockAddr) Network() string

func (*MockAddr) String

func (m *MockAddr) String() string

type MockFile

type MockFile struct {
	MWR MockWriteReader
}

func (*MockFile) Close

func (m *MockFile) Close() error

func (*MockFile) Read

func (m *MockFile) Read(b []byte) (n int, err error)

func (*MockFile) SetLastRead

func (m *MockFile) SetLastRead(n int)

func (*MockFile) Write

func (m *MockFile) Write(b []byte) (n int, err error)

func (*MockFile) WriteString

func (m *MockFile) WriteString(s string) (n int, err error)

type MockHTTPWriter

type MockHTTPWriter struct {
	Data       []byte
	StatusCode int
	HeaderData http.Header
}

MockHTTPWriter is meant to implement http.ResponseWriter interface. It can be useful in various test cases with RESTful API methods that do not return any value to external function but write output directly to HTTP client

func (*MockHTTPWriter) AssertAndFlush

func (m *MockHTTPWriter) AssertAndFlush(t *testing.T, assertWith interface{})

AssertAndFlush uses assert.Equal() to check if current buffer data equals to given example and then cleans buffer.

func (*MockHTTPWriter) Flush

func (m *MockHTTPWriter) Flush()

func (*MockHTTPWriter) Header

func (m *MockHTTPWriter) Header() http.Header

Header returns http.Header in case it was set before or just nil map in other cases

func (*MockHTTPWriter) Write

func (m *MockHTTPWriter) Write(b []byte) (int, error)

Write writes to mock's internal buffer

func (*MockHTTPWriter) WriteHeader

func (m *MockHTTPWriter) WriteHeader(statusCode int)

WriteHeader sets mocks internal status code

type MockTLSConnection

type MockTLSConnection struct {
	MWR MockWriteReader

	AskedToBeClosed bool

	LocAddr net.Addr
	RemAddr net.Addr
}

MockTLSConnection mocks net.Conn interface

func (*MockTLSConnection) Close

func (m *MockTLSConnection) Close() error

func (*MockTLSConnection) LocalAddr

func (m *MockTLSConnection) LocalAddr() net.Addr

func (*MockTLSConnection) Read

func (m *MockTLSConnection) Read(b []byte) (n int, err error)

func (*MockTLSConnection) RemoteAddr

func (m *MockTLSConnection) RemoteAddr() net.Addr

func (*MockTLSConnection) SetDeadline

func (m *MockTLSConnection) SetDeadline(t time.Time) error

func (*MockTLSConnection) SetReadDeadline

func (m *MockTLSConnection) SetReadDeadline(t time.Time) error

func (*MockTLSConnection) SetWriteDeadline

func (m *MockTLSConnection) SetWriteDeadline(t time.Time) error

func (*MockTLSConnection) Write

func (m *MockTLSConnection) Write(b []byte) (n int, err error)

type MockWriteReader

type MockWriteReader struct {
	Bytes []byte

	ReturnEOF        bool //FIle will return EOF at once
	DontReturEOFEver bool
	// contains filtered or unexported fields
}

func (*MockWriteReader) Close

func (l *MockWriteReader) Close() error

func (*MockWriteReader) Read

func (l *MockWriteReader) Read(b []byte) (n int, err error)

func (*MockWriteReader) SetLastRead

func (l *MockWriteReader) SetLastRead(n int)

func (*MockWriteReader) Write

func (l *MockWriteReader) Write(b []byte) (n int, err error)

func (*MockWriteReader) WriteString

func (l *MockWriteReader) WriteString(s string) (n int, err error)

Jump to

Keyboard shortcuts

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