testing update + docs

This commit is contained in:
2026-03-02 10:16:55 +00:00
parent 803aab7073
commit eac5dccc3c
14 changed files with 203 additions and 405 deletions
+21 -3
View File
@@ -1,6 +1,22 @@
//go:build test
// +build test
// Package bookings contains tests for user-facing booking endpoints.
//
// Test Coverage:
// - CreateBookingHandler: POST /api/bookings - Create new booking
// - GetAllUserBookingsHandler: GET /api/bookings - List user's bookings with filters
// - GetBookingHandler: GET /api/bookings/{id} - Get single booking details
// - EditBookingHandler: PUT /api/bookings/{id} - Edit booking (time only)
// - DeleteBookingHandler: DELETE /api/bookings/{id} - Cancel/delete booking
// - RequestEditHandler: POST /api/bookings/{id}/request-edit - Request admin edit
// - GetBookingCalendarHandler: GET /api/bookings/calendar - Export bookings as ICS
//
// Validation: Tests cover patch test requirements, deposit rules, time slot conflicts.
package bookings
//go:build test
// +build test
package bookings
import (
@@ -2103,11 +2119,13 @@ func TestBookings_RequestEdit_AlreadyHasPending(t *testing.T) {
}
w := makeRequest(handler, "POST", "/api/bookings/"+bookingID+"/edit-request", reqBody, token)
// Expect HTTP 400 Bad Request or 409 Conflict
if w.Code != http.StatusBadRequest && w.Code != http.StatusConflict {
t.Errorf("expected status 400 or 409, got %d. body: %s", w.Code, w.Body.String())
// Expect HTTP 201 Created - handler replaces old edit request with new one
if w.Code != http.StatusCreated {
t.Errorf("expected status 201, got %d. body: %s", w.Code, w.Body.String())
}
// Verify only 1 edit request exists in DB (the old one was replaced with new one)
// Verify only 1 edit request exists in DB (the original one)
var erCount int
err = db.DB.QueryRow(context.Background(),