Documentation
¶
Overview ¶
Package httpmock provides a minimal mock http.RoundTripper for tests, modeled on gh's pkg/httpmock (simplified). A Registry holds route stubs that are consumed in registration order, which allows simulating retry sequences (e.g. 502 then 200) by registering the same route twice.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Registry ¶
Registry is an http.RoundTripper that serves registered stubs and records every matched request in Requests.
func (*Registry) Register ¶
Register adds a stub. Stubs are matched in registration order and each stub responds at most once.
type Responder ¶
Responder produces the stubbed response for a matched request.
func ErrorResponse ¶
ErrorResponse simulates a transport-level failure (e.g. connection refused).
func JSONResponse ¶
JSONResponse marshals v as the response body with Content-Type application/json.
func StatusStringResponse ¶
StatusStringResponse responds with the given status code and body.
func WithHeader ¶
WithHeader decorates a responder with an extra response header.