Documentation
¶
Overview ¶
Package storefx supplies Store fixtures for tests.
Index ¶
- func Hashes() domain.HashRegistry
- func Init(t testing.TB, opts ...core.StoreOption) core.Store
- func InitEncryptedOn(t testing.TB, drv driver.Driver, pass string, extra ...core.StoreOption)
- func InitOn(t testing.TB, drv driver.Driver, opts ...core.StoreOption) core.Store
- func InitPlainOn(t testing.TB, drv driver.Driver, extra ...core.StoreOption)
- func InitWithRoot(t testing.TB, opts ...core.StoreOption) (core.Store, string)
- func OpenOn(t testing.TB, drv driver.Driver, extra ...core.StoreOption) core.Store
- func Payload(content string) domain.Artifact
- func RecordingPP(pass string, log *[]core.PassphraseHint) core.PassphraseProvider
- func ScriptedPP(values ...string) core.PassphraseProvider
- func StaticPP(pass string) core.PassphraseProvider
- func TryOpenOn(t testing.TB, drv driver.Driver, extra ...core.StoreOption) (core.Store, error)
- type OnDisk
- func (d OnDisk) BlobCount() int
- func (d OnDisk) BlobFiles() []string
- func (d OnDisk) ManifestExists(id domain.ArtifactID) bool
- func (d OnDisk) ManifestPath(id domain.ArtifactID) string
- func (d OnDisk) ReadManifest(t testing.TB, id domain.ArtifactID) domain.Manifest
- func (d OnDisk) StagingFiles() []string
- type Reopener
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Hashes ¶
func Hashes() domain.HashRegistry
Hashes returns a HashRegistry suitable for tests. sha256 is real; blake3 is registered as an sha256-backed stub so tests that set ContentHasher: HashBLAKE3 do not need to pull in a blake3 library. Tests that care about a specific algorithm register their own.
func Init ¶
Init: fresh Store on localfs + in-memory sqlite index + sha256. Caller opts append to (and can override) defaults.
func InitEncryptedOn ¶
InitEncryptedOn bootstraps an encrypted Store on a caller-provided driver. A fresh in-memory index is wired up internally, then discarded — the caller's intent with this helper is to seed an on-disk Location and immediately exercise OpenStore against it (e.g. to verify the full bootstrap path on a deliberately damaged Location). For tests that want to keep using the same (drv, idx) pair across init+reopen, see InitEncrypted + Reopener.Open.
func InitOn ¶
InitOn wires Init around a caller-provided driver. Caller also owns the index — pass core.WithStoreIndex explicitly.
func InitPlainOn ¶
InitPlainOn is the Plain-DEK counterpart of InitEncryptedOn: bootstrap on a caller-supplied driver with a discarded index, no passphrase. Use to seed a Location for subsequent OpenStore scenarios that do not need a Reopener.
func InitWithRoot ¶
InitWithRoot is Init plus the driver root for on-disk inspection.
func OpenOn ¶
OpenOn is the fatal variant of TryOpenOn: it calls t.Fatalf when OpenStore returns an error and returns just the Store on success.
func RecordingPP ¶
func RecordingPP(pass string, log *[]core.PassphraseHint) core.PassphraseProvider
RecordingPP returns the configured passphrase but records every PassphraseHint it sees into log. Use when the test asserts on Reason / StoreID values that the engine threads through the provider call.
log is appended to, not reset — pass a fresh slice per test.
func ScriptedPP ¶
func ScriptedPP(values ...string) core.PassphraseProvider
ScriptedPP returns a different passphrase per call, driven by values. Use to script provider behaviour across two-call methods (RotateKEK invokes the provider twice — current then new). Returns an error after the script is exhausted.
func StaticPP ¶
func StaticPP(pass string) core.PassphraseProvider
StaticPP is a one-line PassphraseProvider for tests: returns the same passphrase regardless of hint. Use when the test only needs one valid credential.
Types ¶
type OnDisk ¶
type OnDisk struct {
Root string
}
OnDisk wraps a localfs root for physical inspection. Construct via OnDiskAt(root) or via the Reopener.OnDisk() shortcut.
Methods that take *testing.TB call t.Fatalf on unexpected I/O — a stat-error means the test's setup is wrong, not the engine's behaviour.
func (OnDisk) BlobCount ¶
BlobCount returns the number of regular files under <root>/blobs/. A missing blobs/ directory counts as zero.
func (OnDisk) BlobFiles ¶
BlobFiles returns the absolute paths of every regular file under <root>/blobs/. Order is filepath.Walk-driven (lexicographic). A missing blobs/ directory yields an empty slice.
func (OnDisk) ManifestExists ¶
func (d OnDisk) ManifestExists(id domain.ArtifactID) bool
ManifestExists reports whether the manifest file for id is present on disk. Used after Delete to assert physical removal.
func (OnDisk) ManifestPath ¶
func (d OnDisk) ManifestPath(id domain.ArtifactID) string
ManifestPath returns the on-disk path of the manifest file for the given ArtifactID, computed via the same blobpath helper that core uses internally. Tests use this to assert manifest presence or absence without re-implementing the shard rule.
Returns an empty string if blobpath rejects the ID — callers should treat that as a test setup error and fail explicitly.
func (OnDisk) ReadManifest ¶
ReadManifest decodes the manifest file at id. Used to inspect fields that Walk does not return (LayoutHeader, InlineBlob, Pipeline, Metadata) — the index is a routing layer, not a source of truth for manifest content.
Calls t.Fatalf on read or decode failure.
func (OnDisk) StagingFiles ¶
StagingFiles returns regular files under <root>/system.state/staging/. A non-empty result after a completed operation indicates a leak.
type Reopener ¶
type Reopener struct {
// contains filtered or unexported fields
}
Reopener captures the (Driver, StoreIndex) pair so a test can reopen the same Location across the engine boundary. drv and idx outlive any individual core.Store; the Reopener exists for scenarios where the test sequence is "Init → close store → reopen with different options" — common in encrypted-Store flows where the second open uses AutoUnlock or a new passphrase.
Reopener does NOT register cleanup for drv/idx — those are already cleaned up by the underlying driverfx / indexfx fixtures against t.
func InitEncrypted ¶
InitEncrypted bootstraps a fresh encrypted Store with the given passphrase and returns a Reopener. The Store is fully Unlocked after Init (per the Plain-DEK→Encrypted transition described in core/lifecycle.go's InitStore).
extra options are appended to the engine's defaults; pass core.WithKDFParams or core.WithConfig as needed.
func InitEncryptedLocked ¶
func InitEncryptedLocked(t testing.TB, pass string, extra ...core.StoreOption) (core.Store, *Reopener)
InitEncryptedLocked bootstraps an encrypted Store and reopens it WITHOUT AutoUnlock so the returned Store is in StateLocked. The PassphraseProvider configured on the second open uses the same passphrase — tests that need a different provider can replace it via Reopener.Open with WithPassphrase override.
func InitPlain ¶
InitPlain bootstraps a fresh Plain Store and returns a Reopener bound to the same (drv, idx) so the test can reopen the Location later. Use whenever the test exercises a reopen-flow; for single-Init tests, plain Init/InitWithRoot remain shorter.
func (*Reopener) Driver ¶
Driver returns the underlying driver. Tests use this for direct on-disk inspection (descriptor.Read, raw drv.Get on a known path).
func (*Reopener) Index ¶
func (r *Reopener) Index() core.StoreIndex
Index returns the captured StoreIndex.
func (*Reopener) Open ¶
Open reopens the captured Location. WithStoreIndex and WithHashRegistry are filled in automatically; pass any other option (WithPassphrase, WithAutoUnlock, WithConfig, ...) through extra. Calls t.Fatalf on failure.