testutil

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package testutil provides test helpers and assertions for middleware tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertBodyContains

func AssertBodyContains(t *testing.T, rec *celeristest.ResponseRecorder, substr string)

AssertBodyContains fails the test if the body does not contain substr.

func AssertBodyEmpty

func AssertBodyEmpty(t *testing.T, rec *celeristest.ResponseRecorder)

AssertBodyEmpty fails the test if the body is not empty.

func AssertError

func AssertError(t *testing.T, err error)

AssertError fails the test if err is nil.

func AssertHTTPError

func AssertHTTPError(t *testing.T, err error, expectedCode int)

AssertHTTPError fails the test if err is not an *celeris.HTTPError with the expected code.

func AssertHeader

func AssertHeader(t *testing.T, rec *celeristest.ResponseRecorder, key, expected string)

AssertHeader fails the test if the header value does not match expected.

func AssertHeaderContains

func AssertHeaderContains(t *testing.T, rec *celeristest.ResponseRecorder, key, substr string)

AssertHeaderContains fails the test if no header entry for key contains substr. When multiple entries exist for the same key (e.g., from AddHeader), all entries are checked and the assertion passes if any one contains substr.

func AssertNoError

func AssertNoError(t *testing.T, err error)

AssertNoError fails the test if err is not nil.

func AssertNoHeader

func AssertNoHeader(t *testing.T, rec *celeristest.ResponseRecorder, key string)

AssertNoHeader fails the test if any header entry exists for key.

func AssertStatus

func AssertStatus(t *testing.T, rec *celeristest.ResponseRecorder, expected int)

AssertStatus fails the test if the recorder's status code does not match expected.

func RunChain

func RunChain(t *testing.T, chain []celeris.HandlerFunc, method, path string, opts ...celeristest.Option) (*celeristest.ResponseRecorder, error)

RunChain creates a test context with the given handler chain and executes it. The first handler in the chain is called, and each c.Next() progresses through the remaining handlers.

func RunMiddleware

func RunMiddleware(t *testing.T, mw celeris.HandlerFunc, opts ...celeristest.Option) (*celeristest.ResponseRecorder, error)

RunMiddleware creates a test context with GET / and runs the middleware. c.Next() returns nil (no-op handler) for isolated middleware testing.

func RunMiddlewareWithMethod

func RunMiddlewareWithMethod(t *testing.T, mw celeris.HandlerFunc, method, path string, opts ...celeristest.Option) (*celeristest.ResponseRecorder, error)

RunMiddlewareWithMethod creates a test context with the given method and path, then runs the middleware.

Types

This section is empty.

Jump to

Keyboard shortcuts

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