Documentation
¶
Overview ¶
Package testutil holds the fake gateway server the package's own tests are written against. It is internal and never reaches an application build.
Index ¶
- func Capture(t *testing.T, target any, body string) http.HandlerFunc
- func CaptureForm(t *testing.T, target *map[string]string, body string) http.HandlerFunc
- func JSON(body string) http.HandlerFunc
- func NewServer(t *testing.T, routes Routes) *httptest.Server
- func SOAPBody(payload string) http.HandlerFunc
- func Status(code int, body string) http.HandlerFunc
- func XML(body string) http.HandlerFunc
- type Routes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Capture ¶
Capture records the decoded JSON body of a request into target and then answers with the canned body.
func CaptureForm ¶
CaptureForm records the form values of a request and answers with the canned body.
func NewServer ¶
NewServer starts a fake gateway serving routes. Unknown paths fail the test, which turns a wrong endpoint into an immediate, readable failure.
func SOAPBody ¶
func SOAPBody(payload string) http.HandlerFunc
SOAPBody wraps a payload in a SOAP envelope, so a SOAP gateway can be answered without hand writing the envelope in every test.
Types ¶
type Routes ¶
type Routes map[string]http.HandlerFunc
Routes maps a request path to the handler answering it.