neomatest

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package neomatest provides testing utilities for neoma APIs, including an in-memory adapter for sending requests and inspecting responses without starting a real HTTP server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpRequest

func DumpRequest(req *http.Request) ([]byte, error)

DumpRequest serializes an HTTP request, including its body, into a byte slice suitable for logging.

func DumpResponse

func DumpResponse(resp *http.Response) ([]byte, error)

DumpResponse serializes an HTTP response, including its body, into a byte slice suitable for logging.

func NewAdapter

func NewAdapter() core.Adapter

NewAdapter returns a new standard library adapter backed by an in-memory ServeMux, useful for tests that need a standalone adapter.

func NewContext

func NewContext(op *core.Operation, r *http.Request, w http.ResponseWriter) core.Context

NewContext creates a new core.Context from the given operation, request, and response writer, backed by the standard library adapter.

func PrintRequest

func PrintRequest(req *http.Request)

PrintRequest writes a formatted dump of the HTTP request to stdout.

func PrintResponse

func PrintResponse(resp *http.Response)

PrintResponse writes a formatted dump of the HTTP response to stdout.

Types

type TB

type TB interface {
	Helper()
	Log(args ...any)
	Logf(format string, args ...any)
}

TB is a subset of testing.TB used for logging during test requests.

type TestAPI

type TestAPI interface {
	core.API
	DoCtx(ctx context.Context, method, path string, args ...any) *httptest.ResponseRecorder
	Do(method, path string, args ...any) *httptest.ResponseRecorder
}

TestAPI extends core.API with convenience methods for making test requests.

func New

func New(tb TB, configs ...core.Config) (http.Handler, TestAPI)

New creates an in-memory HTTP handler and TestAPI backed by the standard library adapter, ready for use in tests.

func Wrap

func Wrap(tb TB, api core.API) TestAPI

Wrap wraps an existing core.API with test request/response helpers.

Jump to

Keyboard shortcuts

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