Documentation
¶
Overview ¶
Package ledgertest provides throwaway, migrated Postgres databases for tests, without Docker.
Wire it into a test package with TestMain:
func TestMain(m *testing.M) { os.Exit(ledgertest.Run(m)) }
then call ledgertest.NewDB(t) in each test.
By default Run starts an embedded Postgres server (the binary is downloaded once and cached in ~/.embedded-postgres-go). Set LEDGER_TEST_DATABASE_URL to use an existing server instead, e.g. a local Homebrew Postgres:
LEDGER_TEST_DATABASE_URL=postgres://localhost:5432/postgres?sslmode=disable
Either way each NewDB call creates its own database, dropped when the test ends.
Index ¶
Constants ¶
View Source
const EnvDatabaseURL = "LEDGER_TEST_DATABASE_URL"
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.