storetest

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: BSD-3-Clause 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 storetest opens throw-away stores for tests. It imports "testing", so only test code imports it, never the program.

Index

Constants

View Source
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.

View Source
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

func Open(tb testing.TB, clk clock.Clock) *store.Store

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

func OpenLarge(tb testing.TB, clk clock.Clock) *store.Store

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.

func Postgres added in v1.1.0

func Postgres() bool

Postgres reports whether the tests run on PostgreSQL, that is whether the environment variable store.PostgresTestEnv (CLOWDER_TEST_POSTGRES) is set.

Types

type Store added in v1.2.0

type Store = store.Store

Store is the store that Open returns. Tests of packages that must not import internal/store (internal/calls) name it through this alias.

Jump to

Keyboard shortcuts

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