Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TestDB ¶
type TestDB struct {
ConnPool *pgxpool.Pool
Container *tcpgres.PostgresContainer
}
TestDB holds the testcontainer and connection pool.
func NewTestDB ¶
NewTestDB creates a new test database with automatic cleanup. This is the preferred function for most tests.
Usage:
func TestMyRepo(t *testing.T) {
db := testutils.NewTestDB(t)
repo := myrepo.New(db.Pool())
// ... test code
}
The container is automatically terminated when the test completes.
func StartTestDB ¶
StartTestDB starts a PostgreSQL container using Testcontainers. This is a lower-level function for advanced use cases where you need manual control. For most tests, use NewTestDB instead.
Click to show internal directories.
Click to hide internal directories.