Documentation
¶
Index ¶
- type MockRequestRunner
- func (m *MockRequestRunner) Do(request *http.Request) (*http.Response, error)
- func (m *MockRequestRunner) ExpectRequest(method, path string, opts ...ResponseOption)
- func (m *MockRequestRunner) ExpectRequestWithResponse(method, path string, resp *http.Response)
- func (m *MockRequestRunner) ExpectRequestWithResponseFunc(method, path string, resp func(r *http.Request) *http.Response)
- type ResponseOption
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) 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 ¶
type ResponseOption ¶
func WithJSONResponse ¶
func WithJSONResponse(body any) ResponseOption
func WithStatus ¶
func WithStatus(status int) ResponseOption
Click to show internal directories.
Click to hide internal directories.