Documentation
¶
Overview ¶
Package testkit provides small helpers for generated runtime integration tests.
Index ¶
- func AssertEmitted[E any](t testing.TB, events []contracts.EventEnvelope, ...)
- func AssertHeader(t testing.TB, handler http.Handler, method, requestPath, name, want string)
- func AssertNoEvents(t testing.TB, events []contracts.EventEnvelope)
- func AssertStatus(t testing.TB, handler http.Handler, method, requestPath, body string, want int)
- func CaptureCommandEvents[C, R any](t testing.TB, registry *contracts.Registry, command C) (R, []contracts.EventEnvelope)
- func ContractRegistry(register ...func(*contracts.Registry)) *contracts.Registry
- func Response(handler http.Handler, scenario Scenario) *httptest.ResponseRecorder
- func Run(t testing.TB, handler http.Handler, scenarios []Scenario)
- type Scenario
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertEmitted ¶
func AssertEmitted[E any](t testing.TB, events []contracts.EventEnvelope, category contracts.EventCategory, check func(E))
AssertEmitted finds one captured event with the requested category and type.
func AssertHeader ¶
AssertHeader checks one response header value.
func AssertNoEvents ¶
func AssertNoEvents(t testing.TB, events []contracts.EventEnvelope)
AssertNoEvents fails when a command unexpectedly emitted events.
func AssertStatus ¶
AssertStatus checks one request's response status.
func CaptureCommandEvents ¶
func CaptureCommandEvents[C, R any](t testing.TB, registry *contracts.Registry, command C) (R, []contracts.EventEnvelope)
CaptureCommandEvents runs a command and fails the test on command errors.
func ContractRegistry ¶
ContractRegistry creates an in-memory registry for contract tests.
Types ¶
Click to show internal directories.
Click to hide internal directories.