Documentation
¶
Overview ¶
Package transport gives an HTTP-based API client (go-gh's REST/GraphQL clients, or anything else built on http.RoundTripper) a test seam and a safety net in one: a fake transport tests can register, and a guard that panics on a real mutating request reaching the network when no fake is registered.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Current ¶
func Current(base http.RoundTripper) http.RoundTripper
Current returns the registered fake transport, or base wrapped in the mutation guard when none is registered. Call it while building a client under `go test` so every request goes through one or the other; a production build has no reason to call it at all.
func SetTestTransport ¶
func SetTestTransport(rt http.RoundTripper) func()
SetTestTransport routes every client built through Current afterward through rt, so a test never reaches the real network. It returns a restore function and panics when called outside `go test`.
Types ¶
This section is empty.