providerfixture

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package providerfixture owns governed provider-response fixtures for tests.

Index

Constants

View Source
const CurrencyVariable = "STARMAP_PROVIDER_FIXTURE_CURRENCY"

CurrencyVariable selects the live fixture currency comparison. The offline test path never sets it, because only catalog-acquisition credentials can clear a stale or drifted fixture.

Variables

This section is empty.

Functions

func CurrencyRequested added in v0.6.0

func CurrencyRequested() bool

CurrencyRequested reports whether the caller explicitly selected the live fixture currency comparison. scripts/verify-provider-fixture-drift.sh owns it.

func UpdateRequested

func UpdateRequested() bool

UpdateRequested reports whether the caller explicitly selected fixture refresh with the test binary's -update flag.

func WireDrift added in v0.6.0

func WireDrift(recorded, live []byte) (absent, added []string, err error)

WireDrift reports the model fields that a recorded fixture and a live provider response do not share. Absent fields are fields the fixture exercises that the provider no longer returns. Added fields are fields the provider returns that the fixture does not record. Either direction means the fixture no longer mirrors the provider, so the mapping contract it proves is no longer current.

Drift is a stronger currency signal than age: age reports only that a capture is old, while drift names what changed.

func WireModelFields added in v0.6.0

func WireModelFields(payload []byte) ([]string, error)

WireModelFields returns the sorted union of member names across every model object in a provider list response. Every governed provider returns its models in a top-level data array, so one reader serves each protocol.

Types

type Fixture

type Fixture struct {
	Provider     string
	PayloadPath  string
	MetadataPath string
}

Fixture identifies one provider capture and its adjacent metadata.

func Discover

func Discover(root string) ([]Fixture, error)

Discover returns every complete provider fixture below root in provider-ID order.

func Find

func Find(root, provider string) (Fixture, error)

Find resolves one explicit provider fixture below root.

func (Fixture) Capture

func (f Fixture) Capture(payload []byte, capturedAt time.Time) error

Capture replaces the payload and metadata after an explicit live refresh. It preserves the fixture's reviewed maximum-age policy.

func (Fixture) Decode

func (f Fixture) Decode(destination any) error

Decode unmarshals the fixture payload into destination.

func (Fixture) Freshness added in v0.6.0

func (f Fixture) Freshness(now time.Time) (age, maxAge time.Duration, err error)

Freshness reports the fixture's age and its reviewed maximum age. Callers use the remaining margin to report an approaching expiry before it blocks work.

func (Fixture) Read

func (f Fixture) Read() ([]byte, error)

Read returns caller-owned fixture payload bytes.

func (Fixture) Verify

func (f Fixture) Verify(now time.Time) error

Verify validates fixture identity, bytes, source revision, and capture time. It is hermetic and never consults the fixture's maximum-age policy, so offline tests stay deterministic. Use VerifyFreshness for the age policy.

func (Fixture) VerifyFreshness added in v0.6.0

func (f Fixture) VerifyFreshness(now time.Time) error

VerifyFreshness enforces the fixture's reviewed maximum-age policy. Only a live capture can clear a stale fixture, so this belongs to a gate that holds catalog-acquisition credentials, never to the offline test path.

type FixtureMetadata

type FixtureMetadata struct {
	Version        uint64                       `json:"version"`
	Provider       string                       `json:"provider"`
	FetchedAt      time.Time                    `json:"fetched_at"`
	SourceRevision evidence.ObservationRevision `json:"source_revision"`
	Payload        FixturePayload               `json:"payload"`
	MaxAge         string                       `json:"max_age"`
}

FixtureMetadata binds a provider fixture to its source revision and freshness policy.

type FixturePayload

type FixturePayload struct {
	Path     string `json:"path"`
	Checksum string `json:"checksum"`
}

FixturePayload identifies the exact fixture bytes governed by metadata.

Jump to

Keyboard shortcuts

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