mirror of https://github.com/jackc/pgx.git
parent
aff43ee158
commit
08b412740f
|
@ -6,7 +6,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
pgxpool "github.com/jackc/pgx/v4/pool"
|
||||
"github.com/jackc/pgx/v4/pgxpool"
|
||||
)
|
||||
|
||||
var pool *pgxpool.Pool
|
||||
|
|
|
@ -8,11 +8,11 @@ import (
|
|||
|
||||
"github.com/jackc/pgx/v4"
|
||||
"github.com/jackc/pgx/v4/log/log15adapter"
|
||||
"github.com/jackc/pgx/v4/pool"
|
||||
"github.com/jackc/pgx/v4/pgxpool"
|
||||
log "gopkg.in/inconshreveable/log15.v2"
|
||||
)
|
||||
|
||||
var db *pool.Pool
|
||||
var db *pgxpool.Pool
|
||||
|
||||
// afterConnect creates the prepared statements that this application uses
|
||||
func afterConnect(ctx context.Context, conn *pgx.Conn) (err error) {
|
||||
|
@ -95,7 +95,7 @@ func urlHandler(w http.ResponseWriter, req *http.Request) {
|
|||
func main() {
|
||||
logger := log15adapter.NewLogger(log.New("module", "pgx"))
|
||||
|
||||
poolConfig, err := pool.ParseConfig(os.Getenv("DATABASE_URL"))
|
||||
poolConfig, err := pgxpool.ParseConfig(os.Getenv("DATABASE_URL"))
|
||||
if err != nil {
|
||||
log.Crit("Unable to parse DATABASE_URL", "error", err)
|
||||
os.Exit(1)
|
||||
|
@ -104,7 +104,7 @@ func main() {
|
|||
poolConfig.AfterConnect = afterConnect
|
||||
poolConfig.ConnConfig.Logger = logger
|
||||
|
||||
db, err = pool.ConnectConfig(context.Background(), poolConfig)
|
||||
db, err = pgxpool.ConnectConfig(context.Background(), poolConfig)
|
||||
if err != nil {
|
||||
log.Crit("Unable to create connection pool", "error", err)
|
||||
os.Exit(1)
|
||||
|
|
4
go.sum
4
go.sum
|
@ -10,10 +10,6 @@ github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZb
|
|||
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
|
||||
github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3 h1:ZFYpB74Kq8xE9gmfxCmXD6QxZ27ja+j3HwGFc+YurhQ=
|
||||
github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA=
|
||||
github.com/jackc/pgconn v0.0.0-20190424214952-1e3961bd0ea4 h1:NSQwQKGGkrrJDwSoXOV1Mt7c0vpZhudR6g/Eh1+tjpU=
|
||||
github.com/jackc/pgconn v0.0.0-20190424214952-1e3961bd0ea4/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA=
|
||||
github.com/jackc/pgconn v0.0.0-20190527175027-de87e8be96e1 h1:VUwL+salRptMZ7p0scS6LDkwCyCZWVT4TCI5pNQWq8g=
|
||||
github.com/jackc/pgconn v0.0.0-20190527175027-de87e8be96e1/go.mod h1:OJqZ1SRcysK2fKLq9FmQiWAqBiwFwSgOG2WagN1VE+s=
|
||||
github.com/jackc/pgconn v0.0.0-20190528115420-71ec1f782113 h1:EpJHD0fHY9s+K1d2gn0YrVNf2MzCZsgtGgnzKqJGnOw=
|
||||
github.com/jackc/pgconn v0.0.0-20190528115420-71ec1f782113/go.mod h1:f8MMBsyH8EXpj7xNt09B6QAWl1OYflD0QeF6BBCYsdM=
|
||||
github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package pool
|
||||
package pgxpool
|
||||
|
||||
import (
|
||||
"github.com/jackc/pgconn"
|
|
@ -1,4 +1,4 @@
|
|||
package pool_test
|
||||
package pgxpool_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
@ -6,12 +6,12 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/jackc/pgx/v4"
|
||||
"github.com/jackc/pgx/v4/pool"
|
||||
"github.com/jackc/pgx/v4/pgxpool"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func BenchmarkAcquireAndRelease(b *testing.B) {
|
||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(b, err)
|
||||
defer pool.Close()
|
||||
|
||||
|
@ -26,7 +26,7 @@ func BenchmarkAcquireAndRelease(b *testing.B) {
|
|||
}
|
||||
|
||||
func BenchmarkMinimalPreparedSelectBaseline(b *testing.B) {
|
||||
config, err := pool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
|
||||
config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(b, err)
|
||||
|
||||
config.AfterConnect = func(ctx context.Context, c *pgx.Conn) error {
|
||||
|
@ -34,7 +34,7 @@ func BenchmarkMinimalPreparedSelectBaseline(b *testing.B) {
|
|||
return err
|
||||
}
|
||||
|
||||
db, err := pool.ConnectConfig(context.Background(), config)
|
||||
db, err := pgxpool.ConnectConfig(context.Background(), config)
|
||||
require.NoError(b, err)
|
||||
|
||||
conn, err := db.Acquire(context.Background())
|
||||
|
@ -57,7 +57,7 @@ func BenchmarkMinimalPreparedSelectBaseline(b *testing.B) {
|
|||
}
|
||||
|
||||
func BenchmarkMinimalPreparedSelect(b *testing.B) {
|
||||
config, err := pool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
|
||||
config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(b, err)
|
||||
|
||||
config.AfterConnect = func(ctx context.Context, c *pgx.Conn) error {
|
||||
|
@ -65,7 +65,7 @@ func BenchmarkMinimalPreparedSelect(b *testing.B) {
|
|||
return err
|
||||
}
|
||||
|
||||
db, err := pool.ConnectConfig(context.Background(), config)
|
||||
db, err := pgxpool.ConnectConfig(context.Background(), config)
|
||||
require.NoError(b, err)
|
||||
|
||||
var n int64
|
|
@ -1,4 +1,4 @@
|
|||
package pool_test
|
||||
package pgxpool_test
|
||||
|
||||
import (
|
||||
"context"
|
|
@ -1,4 +1,4 @@
|
|||
package pool
|
||||
package pgxpool
|
||||
|
||||
import (
|
||||
"context"
|
|
@ -1,18 +1,18 @@
|
|||
package pool_test
|
||||
package pgxpool_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/jackc/pgx/v4/pool"
|
||||
"github.com/jackc/pgx/v4/pgxpool"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestConnExec(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
||||
|
@ -26,7 +26,7 @@ func TestConnExec(t *testing.T) {
|
|||
func TestConnQuery(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
||||
|
@ -40,7 +40,7 @@ func TestConnQuery(t *testing.T) {
|
|||
func TestConnQueryRow(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
||||
|
@ -54,7 +54,7 @@ func TestConnQueryRow(t *testing.T) {
|
|||
func TestConnSendBatch(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
||||
|
@ -68,7 +68,7 @@ func TestConnSendBatch(t *testing.T) {
|
|||
func TestConnCopyFrom(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package pool
|
||||
package pgxpool
|
||||
|
||||
import (
|
||||
"context"
|
|
@ -1,4 +1,4 @@
|
|||
package pool_test
|
||||
package pgxpool_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
@ -7,7 +7,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v4"
|
||||
"github.com/jackc/pgx/v4/pool"
|
||||
"github.com/jackc/pgx/v4/pgxpool"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -15,7 +15,7 @@ import (
|
|||
func TestConnect(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
pool.Close()
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func TestConnect(t *testing.T) {
|
|||
func TestParseConfigExtractsPoolArguments(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
config, err := pool.ParseConfig("pool_max_conns=42")
|
||||
config, err := pgxpool.ParseConfig("pool_max_conns=42")
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 42, config.MaxConns)
|
||||
assert.NotContains(t, config.ConnConfig.Config.RuntimeParams, "pool_max_conns")
|
||||
|
@ -34,7 +34,7 @@ func TestConnectCancel(t *testing.T) {
|
|||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
pool, err := pool.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
|
||||
assert.Nil(t, pool)
|
||||
assert.Equal(t, context.Canceled, err)
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ func TestConnectCancel(t *testing.T) {
|
|||
func TestPoolAcquireAndConnRelease(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
||||
|
@ -54,7 +54,7 @@ func TestPoolAcquireAndConnRelease(t *testing.T) {
|
|||
func TestPoolAfterConnect(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
config, err := pool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
|
||||
config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
|
||||
config.AfterConnect = func(ctx context.Context, c *pgx.Conn) error {
|
||||
|
@ -62,7 +62,7 @@ func TestPoolAfterConnect(t *testing.T) {
|
|||
return err
|
||||
}
|
||||
|
||||
db, err := pool.ConnectConfig(context.Background(), config)
|
||||
db, err := pgxpool.ConnectConfig(context.Background(), config)
|
||||
require.NoError(t, err)
|
||||
defer db.Close()
|
||||
|
||||
|
@ -75,7 +75,7 @@ func TestPoolAfterConnect(t *testing.T) {
|
|||
func TestPoolBeforeAcquire(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
config, err := pool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
|
||||
config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
|
||||
acquireAttempts := 0
|
||||
|
@ -85,11 +85,11 @@ func TestPoolBeforeAcquire(t *testing.T) {
|
|||
return acquireAttempts%2 == 0
|
||||
}
|
||||
|
||||
db, err := pool.ConnectConfig(context.Background(), config)
|
||||
db, err := pgxpool.ConnectConfig(context.Background(), config)
|
||||
require.NoError(t, err)
|
||||
defer db.Close()
|
||||
|
||||
conns := make([]*pool.Conn, 4)
|
||||
conns := make([]*pgxpool.Conn, 4)
|
||||
for i := range conns {
|
||||
conns[i], err = db.Acquire(context.Background())
|
||||
assert.NoError(t, err)
|
||||
|
@ -116,7 +116,7 @@ func TestPoolBeforeAcquire(t *testing.T) {
|
|||
func TestPoolAfterRelease(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
config, err := pool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
|
||||
config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
|
||||
afterReleaseCount := 0
|
||||
|
@ -126,7 +126,7 @@ func TestPoolAfterRelease(t *testing.T) {
|
|||
return afterReleaseCount%2 == 1
|
||||
}
|
||||
|
||||
db, err := pool.ConnectConfig(context.Background(), config)
|
||||
db, err := pgxpool.ConnectConfig(context.Background(), config)
|
||||
require.NoError(t, err)
|
||||
defer db.Close()
|
||||
|
||||
|
@ -146,7 +146,7 @@ func TestPoolAfterRelease(t *testing.T) {
|
|||
func TestPoolAcquireAllIdle(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
db, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
db, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer db.Close()
|
||||
|
||||
|
@ -158,7 +158,7 @@ func TestPoolAcquireAllIdle(t *testing.T) {
|
|||
}
|
||||
waitForReleaseToComplete()
|
||||
|
||||
conns = make([]*pool.Conn, 3)
|
||||
conns = make([]*pgxpool.Conn, 3)
|
||||
for i := range conns {
|
||||
conns[i], err = db.Acquire(context.Background())
|
||||
assert.NoError(t, err)
|
||||
|
@ -182,12 +182,12 @@ func TestPoolAcquireAllIdle(t *testing.T) {
|
|||
func TestConnReleaseChecksMaxConnLifetime(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
config, err := pool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
|
||||
config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
|
||||
config.MaxConnLifetime = 250 * time.Millisecond
|
||||
|
||||
db, err := pool.ConnectConfig(context.Background(), config)
|
||||
db, err := pgxpool.ConnectConfig(context.Background(), config)
|
||||
defer db.Close()
|
||||
|
||||
c, err := db.Acquire(context.Background())
|
||||
|
@ -205,13 +205,13 @@ func TestConnReleaseChecksMaxConnLifetime(t *testing.T) {
|
|||
func TestPoolBackgroundChecksMaxConnLifetime(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
config, err := pool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
|
||||
config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
|
||||
config.MaxConnLifetime = 100 * time.Millisecond
|
||||
config.HealthCheckPeriod = 100 * time.Millisecond
|
||||
|
||||
db, err := pool.ConnectConfig(context.Background(), config)
|
||||
db, err := pgxpool.ConnectConfig(context.Background(), config)
|
||||
defer db.Close()
|
||||
|
||||
c, err := db.Acquire(context.Background())
|
||||
|
@ -226,7 +226,7 @@ func TestPoolBackgroundChecksMaxConnLifetime(t *testing.T) {
|
|||
func TestPoolExec(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
||||
|
@ -236,7 +236,7 @@ func TestPoolExec(t *testing.T) {
|
|||
func TestPoolQuery(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
||||
|
@ -265,7 +265,7 @@ func TestPoolQuery(t *testing.T) {
|
|||
func TestPoolQueryRow(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
||||
|
@ -280,7 +280,7 @@ func TestPoolQueryRow(t *testing.T) {
|
|||
func TestPoolSendBatch(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
||||
|
@ -300,7 +300,7 @@ func TestPoolCopyFrom(t *testing.T) {
|
|||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
pool, err := pool.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
||||
|
@ -343,7 +343,7 @@ func TestConnReleaseClosesConnInFailedTransaction(t *testing.T) {
|
|||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
pool, err := pool.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
||||
|
@ -381,7 +381,7 @@ func TestConnReleaseClosesConnInTransaction(t *testing.T) {
|
|||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
pool, err := pool.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
||||
|
@ -414,7 +414,7 @@ func TestConnReleaseDestroysClosedConn(t *testing.T) {
|
|||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
pool, err := pool.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
||||
|
@ -434,7 +434,7 @@ func TestConnReleaseDestroysClosedConn(t *testing.T) {
|
|||
func TestConnPoolQueryConcurrentLoad(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package pool
|
||||
package pgxpool
|
||||
|
||||
import (
|
||||
"github.com/jackc/pgproto3/v2"
|
|
@ -1,4 +1,4 @@
|
|||
package pool
|
||||
package pgxpool
|
||||
|
||||
import (
|
||||
"time"
|
|
@ -1,4 +1,4 @@
|
|||
package pool
|
||||
package pgxpool
|
||||
|
||||
import (
|
||||
"context"
|
|
@ -1,18 +1,18 @@
|
|||
package pool_test
|
||||
package pgxpool_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/jackc/pgx/v4/pool"
|
||||
"github.com/jackc/pgx/v4/pgxpool"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestTxExec(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
||||
|
@ -26,7 +26,7 @@ func TestTxExec(t *testing.T) {
|
|||
func TestTxQuery(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
||||
|
@ -40,7 +40,7 @@ func TestTxQuery(t *testing.T) {
|
|||
func TestTxQueryRow(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
||||
|
@ -54,7 +54,7 @@ func TestTxQueryRow(t *testing.T) {
|
|||
func TestTxSendBatch(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
||||
|
@ -68,7 +68,7 @@ func TestTxSendBatch(t *testing.T) {
|
|||
func TestTxCopyFrom(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pool, err := pool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.NoError(t, err)
|
||||
defer pool.Close()
|
||||
|
Loading…
Reference in New Issue