Do a simple query to ensure the connection is still usable
(t *testing.T, pgConn *pgconn.PgConn)
| 24 | |
| 25 | // Do a simple query to ensure the connection is still usable |
| 26 | func ensureConnValid(t *testing.T, pgConn *pgconn.PgConn) { |
| 27 | ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) |
| 28 | result := pgConn.ExecParams(ctx, "select generate_series(1,$1)", [][]byte{[]byte("3")}, nil, nil, nil).Read() |
| 29 | cancel() |
| 30 | |
| 31 | require.Nil(t, result.Err) |
| 32 | assert.Equal(t, 3, len(result.Rows)) |
| 33 | assert.Equal(t, "1", string(result.Rows[0][0])) |
| 34 | assert.Equal(t, "2", string(result.Rows[1][0])) |
| 35 | assert.Equal(t, "3", string(result.Rows[2][0])) |
| 36 | } |
no test coverage detected