Documentation
¶
Overview ¶
Package storetest opens throw-away stores for tests. It imports "testing", so only test code imports it, never the program.
Index ¶
Constants ¶
const LargeDemoEnv = "CLOWDER_BENCH_DB"
LargeDemoEnv is the environment variable that names the database file of a large demo (`clowder demo -size large`, SPEC §10) for the benchmarks.
const LargeDemoPostgresEnv = "CLOWDER_BENCH_DATABASE_URL"
LargeDemoPostgresEnv is the environment variable that names the PostgreSQL database of a large demo (`clowder demo -size large -database-url ...`) for the benchmarks, as a postgres:// URL. It wins over LargeDemoEnv.
Variables ¶
This section is empty.
Functions ¶
func Open ¶
Open returns a Store on a new, empty database, migrated and using clk: a file in the test's temporary directory on SQLite, or, when Postgres is true, a database made with CREATE DATABASE … TEMPLATE on the server of CLOWDER_TEST_POSTGRES. Each call gets its own database, so tests do not see each other's rows, not even in parallel. The Store is closed, and a PostgreSQL database dropped, when the test ends. A failure stops the test.
func OpenLarge ¶
OpenLarge opens the large demo for a benchmark. With LargeDemoPostgresEnv set it opens that PostgreSQL database in place (a benchmark only reads it, apart from the session it logs in with); with LargeDemoEnv set it opens a copy of that SQLite file in the test's temporary directory, so that the benchmark never changes the original. It skips the test or benchmark with a message when neither is set, which keeps the benchmarks out of the default test run. The Store is closed when the test ends. A failure stops the test.