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

Function TestConnBeginTxReadOnly

stdlib/sql_test.go:720–736  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

718}
719
720func TestConnBeginTxReadOnly(t *testing.T) {
721 testWithAllQueryExecModes(t, func(t *testing.T, db *sql.DB) {
722 tx, err := db.BeginTx(context.Background(), &sql.TxOptions{ReadOnly: true})
723 require.NoError(t, err)
724 defer tx.Rollback()
725
726 var pgReadOnly string
727 err = tx.QueryRow("show transaction_read_only").Scan(&pgReadOnly)
728 if err != nil {
729 t.Errorf("QueryRow failed: %v", err)
730 }
731
732 if pgReadOnly != "on" {
733 t.Errorf("pgReadOnly => %s, want %s", pgReadOnly, "on")
734 }
735 })
736}
737
738func TestBeginTxContextCancel(t *testing.T) {
739 testWithAllQueryExecModes(t, func(t *testing.T, db *sql.DB) {

Callers

nothing calls this directly

Calls 5

RollbackMethod · 0.65
ScanMethod · 0.65
QueryRowMethod · 0.65
BeginTxMethod · 0.45

Tested by

no test coverage detected