Run pool tests parallel
This commit is contained in:
+2
-10
@@ -23,17 +23,9 @@ type execer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testExec(t *testing.T, db execer) {
|
func testExec(t *testing.T, db execer) {
|
||||||
results, err := db.Exec(context.Background(), "create table foo(id integer primary key);")
|
results, err := db.Exec(context.Background(), "set time zone 'America/Chicago'")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, "CREATE TABLE", string(results))
|
assert.EqualValues(t, "SET", results)
|
||||||
|
|
||||||
results, err = db.Exec(context.Background(), "insert into foo(id) values($1)", 1)
|
|
||||||
require.NoError(t, err)
|
|
||||||
assert.Equal(t, "INSERT 0 1", string(results))
|
|
||||||
|
|
||||||
results, err = db.Exec(context.Background(), "drop table foo;")
|
|
||||||
require.NoError(t, err)
|
|
||||||
assert.Equal(t, "DROP TABLE", string(results))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type queryer interface {
|
type queryer interface {
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestConnExec(t *testing.T) {
|
func TestConnExec(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
@@ -22,6 +24,8 @@ func TestConnExec(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestConnQuery(t *testing.T) {
|
func TestConnQuery(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
@@ -34,6 +38,8 @@ func TestConnQuery(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestConnQueryRow(t *testing.T) {
|
func TestConnQueryRow(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
@@ -46,6 +52,8 @@ func TestConnQueryRow(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestConnSendBatch(t *testing.T) {
|
func TestConnSendBatch(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
@@ -58,6 +66,8 @@ func TestConnSendBatch(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestConnCopyFrom(t *testing.T) {
|
func TestConnCopyFrom(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
|
|||||||
@@ -13,12 +13,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestConnect(t *testing.T) {
|
func TestConnect(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
pool.Close()
|
pool.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseConfigExtractsPoolArguments(t *testing.T) {
|
func TestParseConfigExtractsPoolArguments(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
config, err := pool.ParseConfig("pool_max_conns=42")
|
config, err := pool.ParseConfig("pool_max_conns=42")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, 42, config.MaxConns)
|
assert.EqualValues(t, 42, config.MaxConns)
|
||||||
@@ -26,6 +30,8 @@ func TestParseConfigExtractsPoolArguments(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestConnectCancel(t *testing.T) {
|
func TestConnectCancel(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
cancel()
|
cancel()
|
||||||
pool, err := pool.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
|
||||||
@@ -34,6 +40,8 @@ func TestConnectCancel(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPoolAcquireAndConnRelease(t *testing.T) {
|
func TestPoolAcquireAndConnRelease(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
@@ -44,6 +52,8 @@ func TestPoolAcquireAndConnRelease(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPoolExec(t *testing.T) {
|
func TestPoolExec(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
@@ -52,6 +62,8 @@ func TestPoolExec(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPoolQuery(t *testing.T) {
|
func TestPoolQuery(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
@@ -79,6 +91,8 @@ func TestPoolQuery(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPoolQueryRow(t *testing.T) {
|
func TestPoolQueryRow(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
@@ -92,6 +106,8 @@ func TestPoolQueryRow(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPoolSendBatch(t *testing.T) {
|
func TestPoolSendBatch(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
@@ -107,6 +123,7 @@ func TestPoolSendBatch(t *testing.T) {
|
|||||||
func TestPoolCopyFrom(t *testing.T) {
|
func TestPoolCopyFrom(t *testing.T) {
|
||||||
// Not able to use testCopyFrom because it relies on temporary tables and the pool may run subsequent calls under
|
// Not able to use testCopyFrom because it relies on temporary tables and the pool may run subsequent calls under
|
||||||
// different connections.
|
// different connections.
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@@ -150,6 +167,8 @@ func TestPoolCopyFrom(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestConnReleaseRollsBackFailedTransaction(t *testing.T) {
|
func TestConnReleaseRollsBackFailedTransaction(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
pool, err := pool.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
|
||||||
@@ -186,6 +205,8 @@ func TestConnReleaseRollsBackFailedTransaction(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestConnReleaseRollsBackInTransaction(t *testing.T) {
|
func TestConnReleaseRollsBackInTransaction(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
pool, err := pool.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
|
||||||
@@ -217,6 +238,8 @@ func TestConnReleaseRollsBackInTransaction(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestConnReleaseDestroysClosedConn(t *testing.T) {
|
func TestConnReleaseDestroysClosedConn(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
pool, err := pool.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
|
||||||
@@ -237,6 +260,8 @@ func TestConnReleaseDestroysClosedConn(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestConnPoolQueryConcurrentLoad(t *testing.T) {
|
func TestConnPoolQueryConcurrentLoad(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestTxExec(t *testing.T) {
|
func TestTxExec(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
@@ -22,6 +24,8 @@ func TestTxExec(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTxQuery(t *testing.T) {
|
func TestTxQuery(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
@@ -34,6 +38,8 @@ func TestTxQuery(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTxQueryRow(t *testing.T) {
|
func TestTxQueryRow(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
@@ -46,6 +52,8 @@ func TestTxQueryRow(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTxSendBatch(t *testing.T) {
|
func TestTxSendBatch(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
@@ -58,6 +66,8 @@ func TestTxSendBatch(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTxCopyFrom(t *testing.T) {
|
func TestTxCopyFrom(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
|
|||||||
Reference in New Issue
Block a user