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

Function TestConnQuery

stdlib/sql_test.go:304–333  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

302}
303
304func TestConnQuery(t *testing.T) {
305 testWithAllQueryExecModes(t, func(t *testing.T, db *sql.DB) {
306 skipCockroachDB(t, db, "Server issues incorrect ParameterDescription (https://github.com/cockroachdb/cockroach/issues/60907)")
307
308 rows, err := db.Query("select 'foo', n from generate_series($1::int, $2::int) n", int32(1), int32(10))
309 require.NoError(t, err)
310
311 rowCount := int64(0)
312
313 for rows.Next() {
314 rowCount++
315
316 var s string
317 var n int64
318 err := rows.Scan(&s, &n)
319 require.NoError(t, err)
320 if s != "foo" {
321 t.Errorf(`Expected "foo", received "%v"`, s)
322 }
323 if n != rowCount {
324 t.Errorf("Expected %d, received %d", rowCount, n)
325 }
326 }
327 require.NoError(t, rows.Err())
328 require.EqualValues(t, 10, rowCount)
329
330 err = rows.Close()
331 require.NoError(t, err)
332 })
333}
334
335func TestConnConcurrency(t *testing.T) {
336 testWithAllQueryExecModes(t, func(t *testing.T, db *sql.DB) {

Callers

nothing calls this directly

Calls 7

skipCockroachDBFunction · 0.70
QueryMethod · 0.65
NextMethod · 0.65
ScanMethod · 0.65
ErrMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected