sqlitetest

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 9 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 sqlitetest opens SQLite stores for tests with a cheaper setup.

It is for tests only and must not be imported by production code. Opening a fresh state.db applies all migrations, which costs far more under the race detector than the rest of a unit test. OpenState therefore migrates a fresh database once per test binary, keeps its bytes as a template, and copies that template into each new directory. The real sqlite.OpenState still runs on the copy, so schema checks and pragmas are exercised as usual.

Only the state store is templated. The metrics store generates a random incarnation on every new file (ADR 0012 B4), so a copied metrics.db would share its identity with all others. Tests that need metrics stores call sqlite.OpenMetrics directly.

OpenState does not register a cleanup. The caller closes the store, which keeps the close semantics of the helpers it replaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenState

func OpenState(tb testing.TB, dir string) *sqlite.StateStore

OpenState opens dir/state.db. If the file does not exist yet, it is created from the migrated template. An existing file is opened as is, so a test can reopen a directory and keep its data.

Types

This section is empty.

Jump to

Keyboard shortcuts

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