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

Function TestCollectOneRow

rows_test.go:222–233  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

220}
221
222func TestCollectOneRow(t *testing.T) {
223 defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
224 rows, _ := conn.Query(ctx, `select 42`)
225 n, err := pgx.CollectOneRow(rows, func(row pgx.CollectableRow) (int32, error) {
226 var n int32
227 err := row.Scan(&n)
228 return n, err
229 })
230 assert.NoError(t, err)
231 assert.Equal(t, int32(42), n)
232 })
233}
234
235func TestCollectOneRowNotFound(t *testing.T) {
236 defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {

Callers

nothing calls this directly

Calls 3

RunTestMethod · 0.80
QueryMethod · 0.65
ScanMethod · 0.65

Tested by

no test coverage detected