diff --git a/tests/pgkit_test.go b/tests/pgkit_test.go index 2d44b57..1b2cb47 100644 --- a/tests/pgkit_test.go +++ b/tests/pgkit_test.go @@ -139,15 +139,14 @@ func TestGetOneInTransaction(t *testing.T) { q2 := DB.SQL.Select("*").From("accounts") var account Account - tx, err := DB.Conn.BeginTx(ctx, pgx.TxOptions{}) - assert.NoError(t, err) - - defer tx.Rollback(ctx) + err := pgx.BeginFunc(ctx, DB.Conn, func(tx pgx.Tx) error { + if err := DB.TxQuery(tx).GetOne(ctx, q2, &account); err != nil { + return fmt.Errorf("get one: %w", err) + } - err = DB.TxQuery(tx).GetOne(ctx, q2, &account) - assert.NoError(t, err) + return nil + }) - err = tx.Commit(ctx) assert.NoError(t, err) }