Documentation
¶
Overview ¶
Package contracttest provides testing helpers for API contract drift checks.
The helpers assert route contract coverage, OpenAPI operation metadata, typed problem catalogs, and deterministic OpenAPI golden output in application tests.
Index ¶
- func AssertOperationHasResponse(t testing.TB, registry *specs.Registry, method, path string, status int)
- func AssertOperationHasSecurity(t testing.TB, registry *specs.Registry, method, path, scheme string)
- func AssertProblemCatalogHas(t testing.TB, catalog *httpx.ProblemCatalog, code httpx.ProblemCode)
- func AssertRegistryValid(t testing.TB, registry *routecontracts.Registry)
- func AssertRouteCoverage(t testing.TB, registry *routecontracts.Registry, method, pattern string)
- func GoldenOpenAPI(t testing.TB, got, golden []byte)
- func NormalizeOpenAPI(doc []byte) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertOperationHasResponse ¶
func AssertOperationHasResponse(t testing.TB, registry *specs.Registry, method, path string, status int)
AssertOperationHasResponse fails the test when an OpenAPI operation lacks a response status.
func AssertOperationHasSecurity ¶
func AssertOperationHasSecurity(t testing.TB, registry *specs.Registry, method, path, scheme string)
AssertOperationHasSecurity fails the test when an OpenAPI operation lacks a security requirement.
func AssertProblemCatalogHas ¶
func AssertProblemCatalogHas(t testing.TB, catalog *httpx.ProblemCatalog, code httpx.ProblemCode)
AssertProblemCatalogHas fails the test when a problem catalog lacks a code.
func AssertRegistryValid ¶
func AssertRegistryValid(t testing.TB, registry *routecontracts.Registry)
AssertRegistryValid fails the test when a route contract registry has coverage errors.
func AssertRouteCoverage ¶
func AssertRouteCoverage(t testing.TB, registry *routecontracts.Registry, method, pattern string)
AssertRouteCoverage fails the test when method and pattern are not registered.
func GoldenOpenAPI ¶
GoldenOpenAPI fails the test when normalized OpenAPI JSON differs from golden JSON.
func NormalizeOpenAPI ¶
NormalizeOpenAPI returns deterministic indented JSON for OpenAPI comparison.
Types ¶
This section is empty.