@@ -2621,12 +2621,7 @@ func TestContextCancelBegin(t *testing.T) {
2621
2621
runTests (t , dsn , func (dbt * DBTest ) {
2622
2622
dbt .mustExec ("CREATE TABLE test (v INTEGER)" )
2623
2623
ctx , cancel := context .WithCancel (context .Background ())
2624
- conn , err := dbt .db .Conn (ctx )
2625
- if err != nil {
2626
- dbt .Fatal (err )
2627
- }
2628
- defer conn .Close ()
2629
- tx , err := conn .BeginTx (ctx , nil )
2624
+ tx , err := dbt .db .BeginTx (ctx , nil )
2630
2625
if err != nil {
2631
2626
dbt .Fatal (err )
2632
2627
}
@@ -2656,17 +2651,7 @@ func TestContextCancelBegin(t *testing.T) {
2656
2651
dbt .Errorf ("expected sql.ErrTxDone or context.Canceled, got %v" , err )
2657
2652
}
2658
2653
2659
- // The connection is now in an inoperable state - so performing other
2660
- // operations should fail with ErrBadConn
2661
- // Important to exercise isolation level too - it runs SET TRANSACTION ISOLATION
2662
- // LEVEL XXX first, which needs to return ErrBadConn if the connection's context
2663
- // is cancelled
2664
- _ , err = conn .BeginTx (context .Background (), & sql.TxOptions {Isolation : sql .LevelReadCommitted })
2665
- if err != driver .ErrBadConn {
2666
- dbt .Errorf ("expected driver.ErrBadConn, got %v" , err )
2667
- }
2668
-
2669
- // cannot begin a transaction (on a different conn) with a canceled context
2654
+ // Context is canceled, so cannot begin a transaction.
2670
2655
if _ , err := dbt .db .BeginTx (ctx , nil ); err != context .Canceled {
2671
2656
dbt .Errorf ("expected context.Canceled, got %v" , err )
2672
2657
}
0 commit comments