2
0

Replace connection pool

This commit is contained in:
Jack Christensen
2019-04-10 11:09:42 -05:00
parent ec10fdde8b
commit 77a2da2b46
9 changed files with 42 additions and 1602 deletions
+10 -7
View File
@@ -100,23 +100,26 @@ func TestTxCommitWhenTxBroken(t *testing.T) {
func TestTxCommitSerializationFailure(t *testing.T) {
t.Parallel()
pool := createConnPool(t, 5)
defer pool.Close()
c1 := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
defer closeConn(t, c1)
pool.Exec(context.Background(), `drop table if exists tx_serializable_sums`)
_, err := pool.Exec(context.Background(), `create table tx_serializable_sums(num integer);`)
c2 := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
defer closeConn(t, c2)
c1.Exec(context.Background(), `drop table if exists tx_serializable_sums`)
_, err := c1.Exec(context.Background(), `create table tx_serializable_sums(num integer);`)
if err != nil {
t.Fatalf("Unable to create temporary table: %v", err)
}
defer pool.Exec(context.Background(), `drop table tx_serializable_sums`)
defer c1.Exec(context.Background(), `drop table tx_serializable_sums`)
tx1, err := pool.BeginEx(context.Background(), &pgx.TxOptions{IsoLevel: pgx.Serializable})
tx1, err := c1.BeginEx(context.Background(), &pgx.TxOptions{IsoLevel: pgx.Serializable})
if err != nil {
t.Fatalf("BeginEx failed: %v", err)
}
defer tx1.Rollback()
tx2, err := pool.BeginEx(context.Background(), &pgx.TxOptions{IsoLevel: pgx.Serializable})
tx2, err := c2.BeginEx(context.Background(), &pgx.TxOptions{IsoLevel: pgx.Serializable})
if err != nil {
t.Fatalf("BeginEx failed: %v", err)
}