Documentation
¶
Overview ¶
Package runner provides shared conformance-fixture test helpers.
Index ¶
- func AssertCanonicalJSONEqual(t testing.TB, want, got any, label string)
- func ByteDiff(want, got []byte) string
- func CanonicalJSON(data []byte) ([]byte, error)
- func CanonicalJSONLexemes(data []byte) ([]byte, error)
- func DecodeJSONLines(data []byte) ([]json.RawMessage, error)
- func FixtureRoot() string
- func LoadJSON(t testing.TB, family, name string, target any)
- func LoadJSONLines(t testing.TB, family, name string) []json.RawMessage
- func NormalizeFixturePath(value, root string) string
- func ReadFixture(family, name string) ([]byte, error)
- func ReplacePathAliases(value, path, replacement string) string
- func UpdateTUISnapshots() bool
- type Manifest
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertCanonicalJSONEqual ¶ added in v0.4.13
AssertCanonicalJSONEqual fails the test when want and got differ as canonical JSON. Values marshal first, so raw JSON (json.RawMessage) and Go values compare alike; label, when non-empty, prefixes the failure.
func CanonicalJSON ¶
CanonicalJSON normalizes insignificant JSON whitespace and object-key order.
func CanonicalJSONLexemes ¶
CanonicalJSONLexemes sorts object keys while retaining scalar JSON spellings. It is used for wire fixtures where "<" and "\u003c", or 1 and 1.0, are semantically equal JSON but observably different protocol bytes.
func DecodeJSONLines ¶
func DecodeJSONLines(data []byte) ([]json.RawMessage, error)
DecodeJSONLines validates strict LF-delimited JSONL and returns the original line bytes. Each line must contain exactly one JSON value and the stream must end immediately after a final LF.
func FixtureRoot ¶
func FixtureRoot() string
FixtureRoot returns the absolute path to the committed fixture tree.
func LoadJSONLines ¶
func LoadJSONLines(t testing.TB, family, name string) []json.RawMessage
LoadJSONLines loads and validates one JSONL fixture or fails the calling test.
func NormalizeFixturePath ¶ added in v0.4.13
NormalizeFixturePath rewrites root (and its symlink alias) to "<fixture>", with forward slashes, so observed paths are host-independent.
func ReadFixture ¶
ReadFixture reads one file from a fixture family. name may be a slash-separated relative subpath (e.g. "cases/export-surface.json").
func ReplacePathAliases ¶
ReplacePathAliases replaces both a path and its realpath alias.
func UpdateTUISnapshots ¶ added in v0.4.14
func UpdateTUISnapshots() bool
UpdateTUISnapshots reports whether the run should rewrite Orb-owned TUI snapshots instead of comparing against them.
Types ¶
type Manifest ¶
type Manifest struct {
Family string `json:"family"`
UpstreamCommit string `json:"upstreamCommit"`
Generator string `json:"generator"`
Source string `json:"source"`
Files []string `json:"files"`
}
Manifest identifies the upstream source and generator for a fixture family.
type Snapshot ¶ added in v0.4.14
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot is an in-place editor for one Orb-owned fixture file. A nil *Snapshot is the comparison-mode no-op, so call sites read `if !snap.Set(got, ...) { compare }`.
func OpenSnapshot ¶ added in v0.4.14
OpenSnapshot returns an editor for family/name in update mode and nil otherwise. The rewritten file is saved on test cleanup.
func (*Snapshot) Add ¶ added in v0.4.15
Add is Set for presentation members that may not exist yet: when the final path step names an object member that is absent, the member is appended, so Orb-owned presentation vocabulary can grow (a new theme role) without hand-editing fixture shape. Intermediate path steps must already exist, and behavior-shaped values keep no Add call sites, exactly like Set.
Add is grow-only: a member whose source disappeared (a deleted theme role) stays in the fixture, and comparison mode fails on the stale value until it is removed by hand — the deliberate trade for preserving member order.
func (*Snapshot) Has ¶ added in v0.4.14
Has reports whether path exists in the snapshot. It is false in comparison mode, so it may only guard Set calls. Shape-preserving updates branch on it: a member the extraction wrote (even as null) is rewritten, an absent member stays absent.
func (*Snapshot) Set ¶ added in v0.4.14
Set splices value at path (object member names and array indexes) and reports true when the caller should skip its comparison. Values marshal through the wire-format encoder, so replaced members keep JSON.stringify's spelling and untouched members keep their exact bytes.