httpclient_mock

package
v0.2.88 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2025 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 MockRequestRunner

type MockRequestRunner struct {
	Requests []http.Request
	Matchers map[string]func(r *http.Request) *http.Response
}

MockRequestRunner is a helper class that implements the httpclient.RequestRunner interface and may be used as a mock implementation during testing.

func (*MockRequestRunner) Do

func (m *MockRequestRunner) Do(request *http.Request) (*http.Response, error)

func (*MockRequestRunner) ExpectRequest

func (m *MockRequestRunner) ExpectRequest(method, path string, opts ...ResponseOption)

ExpectRequest configures the mock client to expect an HTTP request with a given method and path. The response that should be returned can be configured by providing a list of ResponseOption's.

func (*MockRequestRunner) ExpectRequestWithResponse

func (m *MockRequestRunner) ExpectRequestWithResponse(method, path string, resp *http.Response)

func (*MockRequestRunner) ExpectRequestWithResponseFunc

func (m *MockRequestRunner) ExpectRequestWithResponseFunc(method, path string, resp func(r *http.Request) *http.Response)

type ResponseOption

type ResponseOption func(*http.Response)

func WithJSONResponse

func WithJSONResponse(body any) ResponseOption

func WithStatus

func WithStatus(status int) ResponseOption

Jump to

Keyboard shortcuts

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