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

Function TestOpenTransactionsDiscarded

stdlib/sql_test.go:1401–1426  ·  view source on GitHub ↗

https://github.com/jackc/pgx/pull/2481

(t *testing.T)

Source from the content-addressed store, hash-verified

1399
1400// https://github.com/jackc/pgx/pull/2481
1401func TestOpenTransactionsDiscarded(t *testing.T) {
1402 db := openDB(t)
1403 defer closeDB(t, db)
1404
1405 skipCockroachDB(t, db, "CockroachDB auto commits DDL by default")
1406
1407 db.SetMaxOpenConns(1)
1408 ctx := context.Background()
1409
1410 for range 3 {
1411 func() {
1412 conn, err := db.Conn(ctx)
1413 require.NoError(t, err)
1414 defer conn.Close()
1415
1416 _, err = conn.ExecContext(ctx, "begin;")
1417 require.NoError(t, err)
1418
1419 // If the open transaction is not discarded, the second time this is run it will fail.
1420 _, err = conn.ExecContext(ctx, "create temporary table in_tx_discard_test(id int);")
1421 require.NoError(t, err)
1422 }()
1423 }
1424
1425 ensureDBValid(t, db)
1426}
1427
1428func TestRowsColumnTypeLength(t *testing.T) {
1429 testWithAllQueryExecModes(t, func(t *testing.T, db *sql.DB) {

Callers

nothing calls this directly

Calls 7

openDBFunction · 0.85
closeDBFunction · 0.85
ensureDBValidFunction · 0.85
skipCockroachDBFunction · 0.70
ConnMethod · 0.65
CloseMethod · 0.65
ExecContextMethod · 0.45

Tested by

no test coverage detected