Documentation ¶
Overview ¶
Package httpmock provides boilerplate code necessary for testing functions using http.Client by the Transport method.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHandlerClient ¶
func NewHandlerClient(handler http.HandlerFunc) *http.Client
NewHandlerClient returns *http.Client with Transport replaced with one that only invokes handler to avoid making real calls.
func NewTransportClient ¶
func NewTransportClient(fn RoundTripperFunc) *http.Client
NewTransportClient is a convenience function that returns *http.Client with Transport replaced to avoid making real calls
Types ¶
type RoundTripperFunc ¶
The RoundTripperFunc type is an adapter to allow the use of ordinary functions as HTTP Client transports. If f is a function with the appropriate signature, RoundTripperFunc(f) is a RoundTripper that calls f. This really ought to already be in the net/http/httptest package, it's just like http.HandlerFunc
func HandlerTransport ¶
func HandlerTransport(handler http.HandlerFunc) RoundTripperFunc
HandlerTransport returns a new RoundTripFunc that invokes `handler` and returns the response it wrote.