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

Function closeConn

pgconn/helper_test.go:14–23  ·  view source on GitHub ↗
(t testing.TB, conn *pgconn.PgConn)

Source from the content-addressed store, hash-verified

12)
13
14func closeConn(t testing.TB, conn *pgconn.PgConn) {
15 ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
16 defer cancel()
17 require.NoError(t, conn.Close(ctx))
18 select {
19 case <-conn.CleanupDone():
20 case <-time.After(30 * time.Second):
21 t.Fatal("Connection cleanup exceeded maximum time")
22 }
23}
24
25// Do a simple query to ensure the connection is still usable
26func ensureConnValid(t *testing.T, pgConn *pgconn.PgConn) {

Calls 2

CleanupDoneMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected