conformance

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func Run

func Run(t *testing.T, opts Options)

Run executes the shared Store contract tests using the factories in opts.

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.

Jump to

Keyboard shortcuts

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