Documentation
¶
Overview ¶
Package storetest is the conformance suite of the framework's stores (ADR 0004): what a store does on every backend — in memory, in the data directory, on each database engine —, run by the framework's tests on memory, files and the framework's fake database, and by each engine module's tests on its engine. It is what keeps the test double honest: a product tested in memory sees what its database does.
func TestConformance(t *testing.T) {
storetest.Run(t, storetest.BackendConfig{Name: "sqlite", Options: func(t *testing.T, app string) []app.AppOption {
return []app.AppOption{app.DataDir(t.TempDir()), app.Database("database", sqlite.Engine())}
}})
}
Each case declares a service of its own, with a name of its own, so the cases of one run can share one database: their tables never meet.
Index ¶
Constants ¶
const ( // App is the name of the app every case runs: a database's URL is read // from STORETEST_<NAME>_URL. App string = "storetest" )
const CodeRolledBack errs.Code = 0x00_04_04_01 // 0.4.4.1
CodeRolledBack is the code of the error a case returns from a transaction's function to roll it back — the suite's own, in the framework's range: layer 4, PP 4 this package (ADR 0147 §3). A store never returns it; the case that returned it expects app.Transact to hand it back.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BackendConfig ¶
type BackendConfig struct {
// Name names the backend in the subtests.
Name string
// Options place the stores of the app named app on the backend —
// app.InMemory(), app.DataDir, an app.Database whose URL the environment
// holds —, once per case. A database is named "database": the suite
// gives its calls a minute, as 32 writers of one entity queue on a
// server's lock.
Options func(t *testing.T, app string) []app.AppOption
}
BackendConfig is where Run runs the framework's stores: a name for the subtests and the options that place the stores there.