MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestTransactionStatusTracking

Function TestTransactionStatusTracking

server/conn_test.go:495–530  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

493 }
494}
495
496func TestTransactionStatusTracking(t *testing.T) {
497 c := &clientConn{txStatus: txStatusIdle}
498
499 // Initially should be idle
500 if c.txStatus != txStatusIdle {
501 t.Errorf("initial txStatus = %c, want %c", c.txStatus, txStatusIdle)
502 }
503
504 // BEGIN should set to transaction
505 c.updateTxStatus("BEGIN")
506 if c.txStatus != txStatusTransaction {
507 t.Errorf("after BEGIN txStatus = %c, want %c", c.txStatus, txStatusTransaction)
508 }
509
510 // SELECT should not change status
511 c.updateTxStatus("SELECT")
512 if c.txStatus != txStatusTransaction {
513 t.Errorf("after SELECT txStatus = %c, want %c", c.txStatus, txStatusTransaction)
514 }
515
516 // COMMIT should set back to idle
517 c.updateTxStatus("COMMIT")
518 if c.txStatus != txStatusIdle {
519 t.Errorf("after COMMIT txStatus = %c, want %c", c.txStatus, txStatusIdle)
520 }
521
522 // Test ROLLBACK path
523 c.updateTxStatus("BEGIN")
524 if c.txStatus != txStatusTransaction {
525 t.Errorf("after second BEGIN txStatus = %c, want %c", c.txStatus, txStatusTransaction)
526 }
527 c.updateTxStatus("ROLLBACK")
528 if c.txStatus != txStatusIdle {
529 t.Errorf("after ROLLBACK txStatus = %c, want %c", c.txStatus, txStatusIdle)
530 }
531}
532
533func TestTransactionErrorStatus(t *testing.T) {

Callers

nothing calls this directly

Calls 1

updateTxStatusMethod · 0.95

Tested by

no test coverage detected