Documentation
¶
Overview ¶
Package conformance provides a shared Store contract test suite that can be wired against any memstore.Store implementation. Each subtest receives a fresh store via the factory functions in Options, so backends are exercised identically without sharing state.
Usage:
func TestConformance(t *testing.T) {
conformance.Run(t, conformance.Options{
NewStore: func(t *testing.T) memstore.Store { ... },
NewStoreNS: func(t *testing.T, ns string) memstore.Store { ... }, // optional
SetSupersededBy: func(t *testing.T, supersededByID, targetID int64) { ... }, // optional
})
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Options ¶
type Options struct {
// NewStore returns a fresh, empty store scoped to a test namespace. Called
// once per subtest; the store need not be closed by the caller (use
// t.Cleanup inside the factory).
NewStore func(t *testing.T) memstore.Store
// NewStoreNS is like NewStore but accepts an explicit namespace. Required
// for the NamespaceIsolation subtest; if nil that subtest is skipped.
NewStoreNS func(t *testing.T, namespace string) memstore.Store
// SetSupersededBy forcibly sets superseded_by on the row with id=targetID
// to supersededByID via a raw backend write, bypassing Store validation.
// The wiring closure captures its own db handle and uses backend-native SQL
// (? placeholders for SQLite, $N for Postgres). Required for
// HistoryCycleTerminates; if nil that subtest is skipped.
SetSupersededBy func(t *testing.T, supersededByID, targetID int64)
// NewTwoUserStores returns two stores over the SAME underlying database
// and namespace, scoped to two DIFFERENT users. nil skips the
// UserIsolation family (backends without per-user scoping).
NewTwoUserStores func(t *testing.T) (memstore.Store, memstore.Store)
// NewTwoUserSessionStores returns two SessionStores over the SAME
// database, scoped to two DIFFERENT users. nil skips the
// SessionIsolation family.
NewTwoUserSessionStores func(t *testing.T) (memstore.SessionStore, memstore.SessionStore)
}
Options configures a conformance run. NewStore is required; the others are optional -- subtests that need them are skipped when they are nil.