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

Function TestCollectOneRowNotFound

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

Source from the content-addressed store, hash-verified

233}
234
235func TestCollectOneRowNotFound(t *testing.T) {
236 defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
237 rows, _ := conn.Query(ctx, `select 42 where false`)
238 n, err := pgx.CollectOneRow(rows, func(row pgx.CollectableRow) (int32, error) {
239 var n int32
240 err := row.Scan(&n)
241 return n, err
242 })
243 assert.ErrorIs(t, err, pgx.ErrNoRows)
244 assert.Equal(t, int32(0), n)
245 })
246}
247
248func TestCollectOneRowIgnoresExtraRows(t *testing.T) {
249 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