testutil

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 5 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capture

func Capture(t *testing.T, target any, body string) http.HandlerFunc

Capture records the decoded JSON body of a request into target and then answers with the canned body.

func CaptureForm

func CaptureForm(t *testing.T, target *map[string]string, body string) http.HandlerFunc

CaptureForm records the form values of a request and answers with the canned body.

func JSON

func JSON(body string) http.HandlerFunc

JSON answers with a canned body and HTTP 200.

func NewServer

func NewServer(t *testing.T, routes Routes) *httptest.Server

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.

func Status

func Status(code int, body string) http.HandlerFunc

Status answers with a canned body and the given status code.

func XML

func XML(body string) http.HandlerFunc

XML answers with a canned XML body and HTTP 200.

Types

type Routes

type Routes map[string]http.HandlerFunc

Routes maps a request path to the handler answering it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL