(t *testing.T)
| 615 | } |
| 616 | |
| 617 | func TestConnReleaseClosesBusyConn(t *testing.T) { |
| 618 | t.Parallel() |
| 619 | |
| 620 | ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second) |
| 621 | defer cancel() |
| 622 | |
| 623 | db, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE")) |
| 624 | require.NoError(t, err) |
| 625 | defer db.Close() |
| 626 | |
| 627 | c, err := db.Acquire(ctx) |
| 628 | require.NoError(t, err) |
| 629 | |
| 630 | _, err = c.Query(ctx, "select generate_series(1,10)") |
| 631 | require.NoError(t, err) |
| 632 | |
| 633 | c.Release() |
| 634 | waitForReleaseToComplete() |
| 635 | |
| 636 | // wait for the connection to actually be destroyed |
| 637 | for range 1000 { |
| 638 | if db.Stat().TotalConns() == 0 { |
| 639 | break |
| 640 | } |
| 641 | time.Sleep(time.Millisecond) |
| 642 | } |
| 643 | |
| 644 | stats := db.Stat() |
| 645 | assert.EqualValues(t, 0, stats.TotalConns()) |
| 646 | } |
| 647 | |
| 648 | func TestPoolBackgroundChecksMaxConnLifetime(t *testing.T) { |
| 649 | t.Parallel() |
nothing calls this directly
no test coverage detected