2
0

Pool BeforeAcquire hook takes context

This commit is contained in:
Jack Christensen
2019-08-31 08:57:03 -05:00
parent 486d64daed
commit f20f026b7d
2 changed files with 9 additions and 9 deletions
+4 -4
View File
@@ -88,7 +88,7 @@ func TestPoolBeforeAcquire(t *testing.T) {
acquireAttempts := 0
config.BeforeAcquire = func(c *pgx.Conn) bool {
config.BeforeAcquire = func(ctx context.Context, c *pgx.Conn) bool {
acquireAttempts += 1
return acquireAttempts%2 == 0
}
@@ -110,7 +110,7 @@ func TestPoolBeforeAcquire(t *testing.T) {
assert.EqualValues(t, 8, acquireAttempts)
conns = db.AcquireAllIdle()
conns = db.AcquireAllIdle(context.Background())
assert.Len(t, conns, 2)
for _, c := range conns {
@@ -158,7 +158,7 @@ func TestPoolAcquireAllIdle(t *testing.T) {
require.NoError(t, err)
defer db.Close()
conns := db.AcquireAllIdle()
conns := db.AcquireAllIdle(context.Background())
assert.Len(t, conns, 1)
for _, c := range conns {
@@ -179,7 +179,7 @@ func TestPoolAcquireAllIdle(t *testing.T) {
}
waitForReleaseToComplete()
conns = db.AcquireAllIdle()
conns = db.AcquireAllIdle(context.Background())
assert.Len(t, conns, 3)
for _, c := range conns {