Documentation
¶
Overview ¶
Package testdb opens SQLite files for tests the way production does.
Tests that open their own database with a different DSN (no WAL, no busy timeout, an unlimited pool) fail under CPU and disk load in ways production never does. Use Open and Reopen instead of sql.Open in a test.
This package imports no other package of this module, so any test package can use it without an import cycle. For that reason it cannot call the production DSN builder (dash.dsn, which is private and sits in a package that imports store). It copies the pragmas of dash/store.go dsn. tooldefer/file.go Open uses the first 3 of them. Keep them equal to dash/store.go dsn.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DSN ¶
DSN returns the dash DSN for a file path (dash/store.go dsn): busy_timeout first (the driver runs the pragmas in order, and journal_mode needs a lock), then WAL, synchronous NORMAL, foreign keys and incremental auto_vacuum. The last 2 are inert for the store and tooldefer schemas.
func Open ¶
Open opens the SQLite file at path with the production settings. It closes the database when the test ends. It fails the test with the real error.
func OpenUnchecked ¶
OpenUnchecked is Open without the first connection. It is for a test that opens a broken file (corrupt, unwritable, read-only) on purpose and checks how the code under test fails. It never fails the test on a bad file.
Types ¶
This section is empty.