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

Function TestTxSendBatchClosed

tx_test.go:614–645  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

612}
613
614func TestTxSendBatchClosed(t *testing.T) {
615 t.Parallel()
616
617 db := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
618 defer closeConn(t, db)
619
620 tx, err := db.Begin(context.Background())
621 require.NoError(t, err)
622 defer tx.Rollback(context.Background())
623
624 err = tx.Commit(context.Background())
625 require.NoError(t, err)
626
627 batch := &pgx.Batch{}
628 batch.Queue("select 1")
629 batch.Queue("select 2")
630 batch.Queue("select 3")
631
632 br := tx.SendBatch(context.Background(), batch)
633 defer br.Close()
634
635 var n int
636
637 _, err = br.Exec()
638 require.Error(t, err)
639
640 err = br.QueryRow().Scan(&n)
641 require.Error(t, err)
642
643 _, err = br.Query()
644 require.Error(t, err)
645}

Callers

nothing calls this directly

Calls 13

QueueMethod · 0.95
mustConnectStringFunction · 0.85
closeConnFunction · 0.70
BeginMethod · 0.65
RollbackMethod · 0.65
CommitMethod · 0.65
SendBatchMethod · 0.65
CloseMethod · 0.65
ExecMethod · 0.65
ScanMethod · 0.65
QueryRowMethod · 0.65
QueryMethod · 0.65

Tested by

no test coverage detected