Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBWithPool ¶
type DBWithPool struct {
// contains filtered or unexported fields
}
DBWithPool is a wrapper for a puddle resource for a test database. The database is made available via a preconfigured pgxpool.Pool.
func (*DBWithPool) Pool ¶
func (db *DBWithPool) Pool() *pgxpool.Pool
Pool returns the underlying pgxpool.Pool for the test database.
func (*DBWithPool) Release ¶
func (db *DBWithPool) Release()
Release releases the DBWithPool back to the Manager. This should be called when the test is finished with the database.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages a pool of test databases up to a max size. Each DB keeps a pgxpool.Pool which is available when one is acquired from the Manager. Databases can optionally be prepared with a PrepareFunc before being added into the pool, and cleaned up with a CleanupFunc before being returned to the pool for reuse.
This setup makes it trivial to run fully isolated tests in parallel.
func NewManager ¶
func NewManager(config *pgxpool.Config, maxPoolSize int32, prepare PrepareFunc, cleanup CleanupFunc) (*Manager, error)
NewManager creates a new Manager with the given databaseURL, maxPoolSize, and optional prepare/cleanup funcs.