runner

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package runner provides shared conformance-fixture test helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertCanonicalJSONEqual added in v0.4.13

func AssertCanonicalJSONEqual(t testing.TB, want, got any, label string)

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 ByteDiff

func ByteDiff(want, got []byte) string

ByteDiff reports the first differing byte with compact quoted context.

func CanonicalJSON

func CanonicalJSON(data []byte) ([]byte, error)

CanonicalJSON normalizes insignificant JSON whitespace and object-key order.

func CanonicalJSONLexemes

func CanonicalJSONLexemes(data []byte) ([]byte, error)

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 LoadJSON

func LoadJSON(t testing.TB, family, name string, target any)

LoadJSON loads one JSON fixture or fails the calling test.

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

func NormalizeFixturePath(value, root string) string

NormalizeFixturePath rewrites root (and its symlink alias) to "<fixture>", with forward slashes, so observed paths are host-independent.

func ReadFixture

func ReadFixture(family, name string) ([]byte, error)

ReadFixture reads one file from a fixture family. name may be a slash-separated relative subpath (e.g. "cases/export-surface.json").

func ReplacePathAliases

func ReplacePathAliases(value, path, replacement string) string

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.

func LoadManifest

func LoadManifest(t testing.TB, family string) Manifest

LoadManifest loads a fixture family's manifest or fails the calling test.

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

func OpenSnapshot(tb testing.TB, family, name string) *Snapshot

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

func (snapshot *Snapshot) Add(value any, path ...any) bool

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

func (snapshot *Snapshot) Has(path ...any) bool

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

func (snapshot *Snapshot) Set(value any, path ...any) bool

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.

Jump to

Keyboard shortcuts

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