Add batch test for QueryRow without any rows

refs #1150
pull/1153/head
Jack Christensen 2022-02-05 20:11:58 -06:00
parent 9eccdd6a81
commit d02b2ed013
1 changed files with 7 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package pgx_test
import (
"context"
"errors"
"os"
"testing"
@ -33,6 +34,7 @@ func TestConnSendBatch(t *testing.T) {
batch.Queue("insert into ledger(description, amount) values($1, $2)", "q3", 3)
batch.Queue("select id, description, amount from ledger order by id")
batch.Queue("select id, description, amount from ledger order by id")
batch.Queue("select * from ledger where false")
batch.Queue("select sum(amount) from ledger")
br := conn.SendBatch(context.Background(), batch)
@ -127,6 +129,11 @@ func TestConnSendBatch(t *testing.T) {
t.Error(err)
}
err = br.QueryRow().Scan(&id, &description, &amount)
if !errors.Is(err, pgx.ErrNoRows) {
t.Errorf("expected pgx.ErrNoRows but got: %v", err)
}
err = br.QueryRow().Scan(&amount)
if err != nil {
t.Error(err)