Help us shape the future of Go! Take the 2026 Go Developer Survey

testutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertGolden

func AssertGolden(t *testing.T, path string, got []byte)

AssertGolden compares the data to a golden file.

func DecodeJSON

func DecodeJSON(t *testing.T, rec *httptest.ResponseRecorder, dst any)

DecodeJSON decodes a JSON response into dst.

func Do

func Do(t *testing.T, handler http.Handler, req *http.Request) *httptest.ResponseRecorder

Do executes a request against a handler.

func MustHeader

func MustHeader(t *testing.T, rec *httptest.ResponseRecorder, key, value string)

MustHeader asserts a response header value.

func MustStatus

func MustStatus(t *testing.T, rec *httptest.ResponseRecorder, status int)

MustStatus asserts the response status code.

func RunMiddleware

func RunMiddleware(t *testing.T, middleware []bebo.Middleware, handler bebo.Handler, req *http.Request) (*httptest.ResponseRecorder, error)

RunMiddleware executes middleware with a handler and request.

func RunMiddlewareCases

func RunMiddlewareCases(t *testing.T, cases []MiddlewareCase)

RunMiddlewareCases executes middleware test cases in a table-driven style.

func UpdateGolden

func UpdateGolden() bool

UpdateGolden reports whether golden files should be updated.

Types

type MiddlewareCase

type MiddlewareCase struct {
	Name       string
	Middleware []bebo.Middleware
	Handler    bebo.Handler
	Request    *http.Request
	Assert     func(t *testing.T, rec *httptest.ResponseRecorder, err error)
}

MiddlewareCase describes a middleware test case.

Jump to

Keyboard shortcuts

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