contracttest

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

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

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

func GoldenOpenAPI(t testing.TB, got, golden []byte)

GoldenOpenAPI fails the test when normalized OpenAPI JSON differs from golden JSON.

func NormalizeOpenAPI

func NormalizeOpenAPI(doc []byte) ([]byte, error)

NormalizeOpenAPI returns deterministic indented JSON for OpenAPI comparison.

Types

This section is empty.

Jump to

Keyboard shortcuts

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