awstest

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package awstest provides shared HTTP test helpers for service handler tests. The 300+ handler test files in this repository repeat the same echo.New() + httptest.NewRequest + httptest.NewRecorder + NewContext wiring; these helpers collapse it to a single call so tests focus on inputs and assertions rather than transport plumbing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeJSON

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

DecodeJSON unmarshals the recorder's body into v, failing the test on error.

func NewContext

func NewContext(method, path string, body io.Reader) (*echo.Context, *httptest.ResponseRecorder)

NewContext builds an echo context and response recorder for an httptest request with the given method, path and body (body may be nil). The returned recorder captures the handler's response.

func NewJSONContext

func NewJSONContext(
	t *testing.T, method, path string, payload any,
) (*echo.Context, *httptest.ResponseRecorder)

NewJSONContext is like NewContext but marshals payload to JSON for the request body and sets Content-Type: application/json. A nil payload yields an empty body. It fails the test if marshalling fails.

Types

This section is empty.

Jump to

Keyboard shortcuts

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