diff --git a/pkg/pg/pg.go b/pkg/pg/pg.go index 2007dbb15..a82f052a1 100644 --- a/pkg/pg/pg.go +++ b/pkg/pg/pg.go @@ -14,10 +14,9 @@ import ( func NewSqlxDB(t testing.TB, dbURL string) *sqlx.DB { tests.SkipShortDB(t) - err := RegisterTxDb(dbURL) if err != nil { - t.Errorf("failed to register txdb dialect: %w", err) + t.Errorf("failed to register txdb dialect: %s", err.Error()) return nil } db, err := sqlx.Open(string(TransactionWrappedPostgres), uuid.New().String()) diff --git a/pkg/pg/txdb.go b/pkg/pg/txdb.go index 0cd38a94e..243e9025d 100644 --- a/pkg/pg/txdb.go +++ b/pkg/pg/txdb.go @@ -33,6 +33,13 @@ import ( // See heavyweight.FullTestDB() as a convenience function to help you do this, // but please use sparingly because as it's name implies, it is expensive. func RegisterTxDb(dbURL string) error { + drivers := sql.Drivers() + for _, driver := range drivers { + if driver == string(TransactionWrappedPostgres) { + // TxDB driver already registered + return nil + } + } testing.Init() if !flag.Parsed() { flag.Parse()