Skip to content

Commit

Permalink
fix rollback in tests (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasJenicek authored Jul 1, 2024
1 parent 565f9af commit 7c55126
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions tests/pgkit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 7c55126

Please sign in to comment.