mocks

package
v1.36.3 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrMissingHeader

func ErrMissingHeader(key string) error

func ErrUnexpectedData

func ErrUnexpectedData(data string) error

func ErrUnexpectedHeader

func ErrUnexpectedHeader(key, val string) error

func ErrUnexpectedStatusCode

func ErrUnexpectedStatusCode(code int) error

Types

type MockResponseWriter

type MockResponseWriter struct {
	HeaderMap  http.Header
	StatusCode int
	Body       bytes.Buffer
	WriteErr   bool // Force Write() calls to error.
}

MockResponseWriter is a custom mock implementation of http.ResponseWriter.

func NewMockResponseWriter

func NewMockResponseWriter() *MockResponseWriter

NewMockResponseWriter creates a new instance of MockResponseWriter.

func (*MockResponseWriter) Header

func (rw *MockResponseWriter) Header() http.Header

Header returns the mock headers.

func (*MockResponseWriter) Write

func (rw *MockResponseWriter) Write(p []byte) (int, error)

Write mocks the Write method, which writes the response body.

func (*MockResponseWriter) WriteHeader

func (rw *MockResponseWriter) WriteHeader(statusCode int)

WriteHeader mocks the WriteHeader method, which sets the HTTP status code.

Jump to

Keyboard shortcuts

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