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)")
|
||||
}
|
||||
|
||||
@@ -3357,6 +3357,9 @@ func TestVAT_RoundingConsistency(t *testing.T) {
|
||||
var netAmount sql.NullFloat64
|
||||
var isVATApplicable bool
|
||||
err = tx.QueryRow(ctx, `SELECT is_vat_applicable, vat_amount, net_amount FROM payments WHERE id = $1`, paymentID).Scan(&isVATApplicable, &vatAmount, &netAmount)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to query payment VAT fields: %v", err)
|
||||
}
|
||||
|
||||
if !isVATApplicable {
|
||||
t.Fatal("expected VAT to be applicable")
|
||||
|
||||
@@ -510,7 +510,6 @@ func TestScheduling_GetWorkingHours(t *testing.T) {
|
||||
if day.Source != "default" {
|
||||
t.Errorf("expected source 'default', got %s", day.Source)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,6 +134,9 @@ func TestGetTodayAppointments_OmitsPreviousNameWhenNoHistory(t *testing.T) {
|
||||
VALUES ($1, NOW() + INTERVAL '5 minutes', 'in_progress')
|
||||
RETURNING id
|
||||
`, userID).Scan(&bookingID)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to insert test booking: %v", err)
|
||||
}
|
||||
addBookingService(t, ctx, tx, bookingID, svcID)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/api/admin/today/appointments", nil)
|
||||
@@ -344,6 +347,9 @@ func TestGetPendingApprovals_OmitsPreviousNameWhenNoHistory(t *testing.T) {
|
||||
VALUES ($1, NOW() + INTERVAL '1 day', 'pending')
|
||||
RETURNING id
|
||||
`, userID).Scan(&bookingID)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to insert test booking: %v", err)
|
||||
}
|
||||
addBookingService(t, ctx, tx, bookingID, svcID)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/api/admin/today/pending-approvals", nil)
|
||||
|
||||
Reference in New Issue
Block a user