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

Function TestScanRow

query_test.go:1572–1595  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1570}
1571
1572func TestScanRow(t *testing.T) {
1573 t.Parallel()
1574
1575 conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
1576 defer closeConn(t, conn)
1577
1578 resultReader := conn.PgConn().ExecParams(context.Background(), "select generate_series(1,$1)", [][]byte{[]byte("10")}, nil, nil, nil)
1579
1580 var sum, rowCount int32
1581
1582 for resultReader.NextRow() {
1583 var n int32
1584 err := pgx.ScanRow(conn.TypeMap(), resultReader.FieldDescriptions(), resultReader.Values(), &n)
1585 assert.NoError(t, err)
1586 sum += n
1587 rowCount++
1588 }
1589
1590 _, err := resultReader.Close()
1591
1592 require.NoError(t, err)
1593 assert.EqualValues(t, 10, rowCount)
1594 assert.EqualValues(t, 55, sum)
1595}
1596
1597func TestConnSimpleProtocol(t *testing.T) {
1598 t.Parallel()

Callers

nothing calls this directly

Calls 10

mustConnectStringFunction · 0.85
PgConnMethod · 0.80
NextRowMethod · 0.80
TypeMapMethod · 0.80
closeConnFunction · 0.70
ScanRowMethod · 0.65
FieldDescriptionsMethod · 0.65
ValuesMethod · 0.65
CloseMethod · 0.65
ExecParamsMethod · 0.45

Tested by

no test coverage detected