Skip to content

Commit

Permalink
Use tx instead of underlying conn in test
Browse files Browse the repository at this point in the history
Improves clarity
  • Loading branch information
jackc committed Jun 3, 2023
1 parent 608f39f commit d9560c7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions copy_from_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,11 @@ func TestConnCopyFromEnum(t *testing.T) {
{nil, nil, nil, nil, nil, nil},
}

copyCount, err := conn.CopyFrom(ctx, pgx.Identifier{"foo"}, []string{"a", "b", "c", "d", "e", "f"}, pgx.CopyFromRows(inputRows))
copyCount, err := tx.CopyFrom(ctx, pgx.Identifier{"foo"}, []string{"a", "b", "c", "d", "e", "f"}, pgx.CopyFromRows(inputRows))
require.NoError(t, err)
require.EqualValues(t, len(inputRows), copyCount)

rows, err := conn.Query(ctx, "select * from foo")
rows, err := tx.Query(ctx, "select * from foo")
require.NoError(t, err)

var outputRows [][]any
Expand All @@ -395,6 +395,9 @@ func TestConnCopyFromEnum(t *testing.T) {
t.Errorf("Input rows and output rows do not equal: %v -> %v", inputRows, outputRows)
}

err = tx.Rollback(ctx)
require.NoError(t, err)

ensureConnValid(t, conn)
}

Expand Down

0 comments on commit d9560c7

Please sign in to comment.