MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / TestSpecGoldenNoDrift

Function TestSpecGoldenNoDrift

internal/httpapi/spec_test.go:27–46  ·  view source on GitHub ↗

TestSpecGoldenNoDrift is the contract-drift CI gate (api-v1-redesign §6): the committed spec must byte-for-byte equal the spec rendered from the live handlers, so the file codegen consumes can never lag the server. Regenerate with `make spec` after any handler/annotation change.

(t *testing.T)

Source from the content-addressed store, hash-verified

25// handlers, so the file codegen consumes can never lag the server. Regenerate
26// with `make spec` after any handler/annotation change.
27func TestSpecGoldenNoDrift(t *testing.T) {
28 yaml, err := New(Deps{}).OpenAPIYAML()
29 if err != nil {
30 t.Fatalf("render spec: %v", err)
31 }
32 if *updateSpec {
33 if err := os.WriteFile(specGoldenPath, yaml, 0o644); err != nil {
34 t.Fatalf("write golden: %v", err)
35 }
36 t.Logf("regenerated %s (%d bytes)", specGoldenPath, len(yaml))
37 return
38 }
39 want, err := os.ReadFile(specGoldenPath)
40 if err != nil {
41 t.Fatalf("read spec golden (first time? run `make spec`): %v", err)
42 }
43 if !bytes.Equal(bytes.TrimRight(want, "\n"), bytes.TrimRight(yaml, "\n")) {
44 t.Errorf("committed %s is stale vs the live handlers — run `make spec` to regenerate", specGoldenPath)
45 }
46}
47
48// TestSpecGeneratedFromHandlers is the spec↔server check (api-v1-redesign §6):
49// the OpenAPI document is emitted from the live, registered handlers — never

Callers

nothing calls this directly

Calls 2

OpenAPIYAMLMethod · 0.80
NewFunction · 0.70

Tested by

no test coverage detected