Documentation
¶
Overview ¶
Package providerfixture owns governed provider-response fixtures for tests.
Index ¶
- Constants
- func CurrencyRequested() bool
- func UpdateRequested() bool
- func WireDrift(recorded, live []byte) (absent, added []string, err error)
- func WireModelFields(payload []byte) ([]string, error)
- type Fixture
- func (f Fixture) Capture(payload []byte, capturedAt time.Time) error
- func (f Fixture) Decode(destination any) error
- func (f Fixture) Freshness(now time.Time) (age, maxAge time.Duration, err error)
- func (f Fixture) Read() ([]byte, error)
- func (f Fixture) Verify(now time.Time) error
- func (f Fixture) VerifyFreshness(now time.Time) error
- type FixtureMetadata
- type FixturePayload
Constants ¶
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
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
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 ¶
Fixture identifies one provider capture and its adjacent metadata.
func (Fixture) Capture ¶
Capture replaces the payload and metadata after an explicit live refresh. It preserves the fixture's reviewed maximum-age policy.
func (Fixture) Freshness ¶ added in v0.6.0
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) Verify ¶
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
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 ¶
FixturePayload identifies the exact fixture bytes governed by metadata.