MCPcopy
hub / github.com/jackc/pgx / TestPoolAcquireAllIdle

Function TestPoolAcquireAllIdle

pgxpool/pool_test.go:531–560  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

529}
530
531func TestPoolAcquireAllIdle(t *testing.T) {
532 t.Parallel()
533
534 ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
535 defer cancel()
536
537 db, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
538 require.NoError(t, err)
539 defer db.Close()
540
541 conns := make([]*pgxpool.Conn, 3)
542 for i := range conns {
543 conns[i], err = db.Acquire(ctx)
544 assert.NoError(t, err)
545 }
546
547 for _, c := range conns {
548 if c != nil {
549 c.Release()
550 }
551 }
552 waitForReleaseToComplete()
553
554 conns = db.AcquireAllIdle(ctx)
555 assert.Len(t, conns, 3)
556
557 for _, c := range conns {
558 c.Release()
559 }
560}
561
562func TestPoolReset(t *testing.T) {
563 t.Parallel()

Callers

nothing calls this directly

Calls 7

NewFunction · 0.92
waitForReleaseToCompleteFunction · 0.85
AcquireMethod · 0.80
ReleaseMethod · 0.80
AcquireAllIdleMethod · 0.80
CloseMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected