Documentation
¶
Overview ¶
Package pgtest provides Postgres for integration tests: a Testcontainers server per test package (or FOREMAN_TEST_DATABASE_URL) and a freshly migrated schema per test.
var db *pgtest.Database
func TestMain(m *testing.M) { os.Exit(pgtest.Main(m, &db)) }
pool := db.Pool(t); schema := db.Schema(t, pool)
Index ¶
Constants ¶
View Source
const DefaultImage = "postgres:17"
DefaultImage is the Postgres image used when FOREMAN_TEST_PG_IMAGE is unset.
Variables ¶
This section is empty.
Functions ¶
func LeakOptions ¶
LeakOptions ignores the background goroutines of testcontainers and pgx pools.
Types ¶
type Database ¶
type Database struct {
URL string
// contains filtered or unexported fields
}
Database is a Postgres server shared by the tests of one package.
func Start ¶
Start returns the server named by FOREMAN_TEST_DATABASE_URL, or starts a container from FOREMAN_TEST_PG_IMAGE (default postgres:17).
func (*Database) Close ¶
func (d *Database) Close()
Close stops the container if this package started one.
Click to show internal directories.
Click to hide internal directories.