Documentation ¶
Index ¶
- type TestConn
- func (c TestConn) Begin(ctx context.Context) (pgx.Tx, error)
- func (c TestConn) Exec(ctx context.Context, s string, i ...interface{}) (pgconn.CommandTag, error)
- func (c TestConn) Query(ctx context.Context, s string, i ...interface{}) (pgx.Rows, error)
- func (c TestConn) QueryRow(ctx context.Context, s string, i ...interface{}) pgx.Row
- func (c TestConn) SeedData(data ...string)
- type TestDatabase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TestDatabase ¶
type TestDatabase struct { Address string Container *postgres.PostgresContainer }
TestDatabase is a test utility containing a fully-migrated Postgres instance. To use this, run InitDb within a TestMain function and use the DbInstance to interact with the database as needed (e.g. to insert data prior to testing). Ensure to run TearDown at the end of the tests to clean up.
func InitDb ¶
func InitDb() *TestDatabase
func (*TestDatabase) GetConn ¶
func (db *TestDatabase) GetConn() TestConn
func (*TestDatabase) Restore ¶
func (db *TestDatabase) Restore()
Restore restores the DB to the snapshot backup and re-establishes the connection
func (*TestDatabase) TearDown ¶
func (db *TestDatabase) TearDown()
Click to show internal directories.
Click to hide internal directories.