Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustGetPool ¶
MustGetPool returns a shared *pgxpool.Pool backed by a single postgres testcontainer instance started once per test binary execution.
schema is the full DDL SQL applied after the container is ready. Pass your embed.FS content or a raw SQL string:
dbtest.MustGetPool(t, migrations.CurrentSchemaSQL)
Types ¶
type Querier ¶
Querier is a constructor function that creates a query executor from a transaction. Pass gen.New from your sqlc-generated package.
type Suite ¶
type Suite[Q any] struct { suite.Suite Pool *pgxpool.Pool // contains filtered or unexported fields }
Suite is a generic testify-suite for adapter integration tests.
Each test case gets its own transaction in SetupTest. TearDownTest rolls it back — no data leaks between tests, no TRUNCATE needed.
The adapter receives Q through ctxval.Or(ctx, a.g), so the transaction is picked up transparently without any changes to production code.
func NewSuite ¶
NewSuite creates a Suite with the given querier constructor.
type productAdapterSuite struct {
dbtest.Suite[*gen.Queries]
}
func (s *productAdapterSuite) SetupSuite() {
s.Suite = dbtest.NewSuite(migrations.CurrentSchemaSQL, gen.New)
s.Suite.SetupSuite()
}
func (*Suite[Q]) SetupSuite ¶
func (s *Suite[Q]) SetupSuite()
func (*Suite[Q]) TearDownTest ¶
func (s *Suite[Q]) TearDownTest()