fix: add missing err checks and fix loop termination in tests
This commit is contained in:
@@ -2649,6 +2649,9 @@ func TestUserCancelBooking_PendingNoNotification(t *testing.T) {
|
||||
var status string
|
||||
err = tx.QueryRow(ctx,
|
||||
"SELECT status FROM bookings WHERE id = $1", bookingID).Scan(&status)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to query booking status: %v", err)
|
||||
}
|
||||
if status != "pending" {
|
||||
t.Fatalf("expected booking status 'pending', got %s", status)
|
||||
}
|
||||
@@ -2731,6 +2734,9 @@ func TestUserCancelBooking_TransactionIntegrity(t *testing.T) {
|
||||
var statusBefore string
|
||||
err = tx.QueryRow(ctx,
|
||||
"SELECT status FROM bookings WHERE id = $1", bookingID).Scan(&statusBefore)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to query booking status before cancel: %v", err)
|
||||
}
|
||||
if statusBefore != "confirmed" {
|
||||
t.Fatalf("expected status 'confirmed' before cancel, got %s", statusBefore)
|
||||
}
|
||||
@@ -2750,6 +2756,9 @@ func TestUserCancelBooking_TransactionIntegrity(t *testing.T) {
|
||||
var statusAfter string
|
||||
err = tx.QueryRow(ctx,
|
||||
"SELECT status FROM bookings WHERE id = $1", bookingID).Scan(&statusAfter)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to query booking status after cancel: %v", err)
|
||||
}
|
||||
if statusAfter == "confirmed" {
|
||||
t.Error("booking status should have changed after cancellation (transaction should have committed)")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user