Do a simple query to ensure the connection is still usable
(t testing.TB, conn *pgx.Conn)
| 63 | |
| 64 | // Do a simple query to ensure the connection is still usable |
| 65 | func ensureConnValid(t testing.TB, conn *pgx.Conn) { |
| 66 | var sum, rowCount int32 |
| 67 | |
| 68 | rows, err := conn.Query(context.Background(), "select generate_series(1,$1)", 10) |
| 69 | if err != nil { |
| 70 | t.Fatalf("conn.Query failed: %v", err) |
| 71 | } |
| 72 | defer rows.Close() |
| 73 | |
| 74 | for rows.Next() { |
| 75 | var n int32 |
| 76 | rows.Scan(&n) |
| 77 | sum += n |
| 78 | rowCount++ |
| 79 | } |
| 80 | |
| 81 | if rows.Err() != nil { |
| 82 | t.Fatalf("conn.Query failed: %v", rows.Err()) |
| 83 | } |
| 84 | |
| 85 | if rowCount != 10 { |
| 86 | t.Error("Select called onDataRow wrong number of times") |
| 87 | } |
| 88 | if sum != 55 { |
| 89 | t.Error("Wrong values returned") |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | func assertConfigsEqual(t *testing.T, expected, actual *pgx.ConnConfig, testName string) { |
| 94 | if !assert.NotNil(t, expected) { |
no test coverage detected