storetest

package
v0.2.21 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: GPL-2.0, GPL-3.0 Imports: 7 Imported by: 0

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

func AssertClearManualLockNonDestructive(t TB, s api.Store)

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.

func Suite

func Suite(t *testing.T, newStore func(t *testing.T) api.Store)

Suite runs the engine-agnostic behavioral contract against any api.Store produced by newStore. Each promoted finding is a NAMED subtest so a failure names the exact behaviour that regressed.

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.

Jump to

Keyboard shortcuts

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