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 ¶
- func DumpRequest(req *http.Request) ([]byte, error)
- func DumpResponse(resp *http.Response) ([]byte, error)
- func NewAdapter() core.Adapter
- func NewContext(op *core.Operation, r *http.Request, w http.ResponseWriter) core.Context
- func PrintRequest(req *http.Request)
- func PrintResponse(resp *http.Response)
- type TB
- type TestAPI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DumpRequest ¶
DumpRequest serializes an HTTP request, including its body, into a byte slice suitable for logging.
func DumpResponse ¶
DumpResponse serializes an HTTP response, including its body, into a byte slice suitable for logging.
func NewAdapter ¶
NewAdapter returns a new standard library adapter backed by an in-memory ServeMux, useful for tests that need a standalone adapter.
func NewContext ¶
NewContext creates a new core.Context from the given operation, request, and response writer, backed by the standard library adapter.
func PrintRequest ¶
PrintRequest writes a formatted dump of the HTTP request to stdout.
func PrintResponse ¶
PrintResponse writes a formatted dump of the HTTP response to stdout.
Types ¶
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.