(t *testing.T)
| 553 | } |
| 554 | } |
| 555 | |
| 556 | func TestNestedBeginDetection(t *testing.T) { |
| 557 | // Test that we can detect when a nested BEGIN would occur |
| 558 | // The actual warning is sent in handleQuery, but we test the detection logic here |
| 559 | c := &clientConn{txStatus: txStatusIdle} |
| 560 | |
| 561 | // First BEGIN should work normally |
| 562 | c.updateTxStatus("BEGIN") |
| 563 | if c.txStatus != txStatusTransaction { |
| 564 | t.Errorf("after first BEGIN txStatus = %c, want %c", c.txStatus, txStatusTransaction) |
| 565 | } |
| 566 | |
| 567 | // At this point, a second BEGIN should trigger warning behavior |
| 568 | // In handleQuery, when cmdType == "BEGIN" && c.txStatus == txStatusTransaction, |
| 569 | // we send a warning and return success without calling DuckDB |
| 570 | isNestedBegin := c.txStatus == txStatusTransaction |
| 571 | if !isNestedBegin { |
| 572 | t.Error("expected nested BEGIN to be detected") |
| 573 | } |
| 574 | |
| 575 | // Transaction status should remain 'T' (not change to 'I' or 'E') |
| 576 | // The warning is sent but the transaction continues |
| 577 | if c.txStatus != txStatusTransaction { |
| 578 | t.Errorf("txStatus should still be %c after nested BEGIN detection, got %c", txStatusTransaction, c.txStatus) |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | func TestIsConnectionBroken(t *testing.T) { |
nothing calls this directly
no test coverage detected