Documentation
¶
Overview ¶
Package dbtest runs the CMS's store tests against real database engines in throwaway containers.
The suite exists because the CMS speaks SQL to more than one engine: a test that passes on Postgres proves nothing about MySQL. Each registers a subtest per engine, so a single test body becomes the conformance check for every engine the CMS claims to support.
Tests written against this harness should drive stores through their public API rather than raw SQL. A test that reaches for SQL directly has to be written once per dialect, which is exactly the duplication the harness is meant to remove.
Containers are started lazily, once per engine per test process, and shared by every test in the package. Between tests, Truncate empties the cms_ tables — far cheaper than a fresh database per test. When Docker is not available the whole suite skips rather than fails, so `go test ./...` still passes on a machine without it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Each ¶
Each runs fn as a subtest against every engine under test, handing it a migrated, empty database. Use it as the entry point for any test that touches storage:
func TestPageInsert(t *testing.T) {
dbtest.Each(t, func(t *testing.T, db *sqldb.DB) {
store := content.NewStore(db, "en")
...
})
}
func SkipWithoutDocker ¶ added in v0.9.5
SkipWithoutDocker skips the calling test when there is no usable Docker daemon, so the unit-test suite still runs on machines without one.