21 lines
530 B
Go
21 lines
530 B
Go
//go:build integration
|
|
|
|
package postgres
|
|
|
|
import (
|
|
"github.com/jackc/pgx/v5"
|
|
|
|
"lincodex/backend/internal/port/outbound"
|
|
)
|
|
|
|
// TransactionForIntegrationTest exposes the transaction behind a unit of work
|
|
// to integration tests that write test-only tables. It is compiled only with
|
|
// the integration build tag and is not part of the adapter API.
|
|
func TransactionForIntegrationTest(unit outbound.UnitOfWork) (pgx.Tx, bool) {
|
|
postgresUnit, ok := unit.(*UnitOfWork)
|
|
if !ok {
|
|
return nil, false
|
|
}
|
|
return postgresUnit.tx, true
|
|
}
|