Documentation
¶
Overview ¶
Package storetest provides a shared, engine-agnostic behavioral contract suite for api.Store implementations. It depends ONLY on internal/api, so it pins behaviour at the api.Store seam rather than at one engine's internals (Requirement 14.1). boltstore.DB is the only engine today.
What this suite is ¶
Suite asserts EXACT observable values, not merely "does not error". A single suite pins every resolved finding from the bbolt-store-rewrite design review (Requirement 14.2):
- the three ReconcileState branches (video gone; subtitle gone with a sibling still present; all subtitles gone),
- non-destructive ClearManualLock (rows preserved, lock cleared),
- backoff cleared on SaveDownload,
- DeleteStateByPaths orphan cleanup (rows + backoff + coverage),
- GetState filter / search / limit / offset,
- both CleanupDrift branches (removed languages/providers, Requirement 7.7; adaptive disabled, Requirement 7.8).
Because it asserts exact values it requires a REAL persisting store: a no-op fake (testsupport.NopStore) that discards writes cannot satisfy it, and the boltstore package proves the suite catches a regression by running one promoted invariant (AssertClearManualLockNonDestructive) against a deliberately broken stub and asserting the assertion fails.
Filesystem dependency ¶
ReconcileState classifies each row against the real filesystem (an engine defaults its stat oracle to os.Stat), so the reconcile cases create real video/subtitle files under t.TempDir() and reference those paths. This keeps the suite engine-agnostic: it drives reconcile entirely through SaveDownload + RecordNoResult + RecordScanState and real files, with no engine-specific stat injection.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertClearManualLockNonDestructive ¶ added in v0.1.54
AssertClearManualLockNonDestructive asserts ClearManualLock is a NON-destructive flag flip: the lock is cleared but the rows are preserved and stay visible to GetState and DownloadedRefs (Requirement 4.3). It is exported and written against TB so the boltstore package can run it against a deliberately broken (destructive) stub and assert the assertion fails — proving the suite catches the regression.
Types ¶
type TB ¶ added in v0.1.54
type TB interface {
Helper()
Errorf(format string, args ...any)
Fatalf(format string, args ...any)
}
TB is the subset of *testing.T the reusable behavioural assertions need. Real callers pass *testing.T; the broken-stub self-check (in the boltstore package) passes a recorder that captures whether a failure was reported, proving the suite catches a non-conforming store without failing the parent test. *testing.T satisfies TB.