Test docstrings
This commit is contained in:
@@ -55,7 +55,8 @@ import (
|
||||
// List Admin Bookings Tests
|
||||
// =============================================================================
|
||||
|
||||
func TestAdminBookings_List(t *testing.T) {
|
||||
// TestAdminBookings_List verifies that an admin can list all bookings in the
|
||||
// system with pagination support.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -110,7 +111,8 @@ func TestAdminBookings_List(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminBookings_List_FilterByStatus(t *testing.T) {
|
||||
// TestAdminBookings_List_FilterByStatus tests that an admin can filter
|
||||
// bookings by status (e.g., pending, confirmed, completed).
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -173,7 +175,8 @@ func TestAdminBookings_List_FilterByStatus(t *testing.T) {
|
||||
// Admin Create Booking Tests
|
||||
// =============================================================================
|
||||
|
||||
func TestAdminBookings_Create(t *testing.T) {
|
||||
// TestAdminBookings_Create verifies that an admin can create a booking
|
||||
// on behalf of a user. The booking is created with 'confirmed' status.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -229,7 +232,9 @@ func TestAdminBookings_Create(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminBookings_Create_InvalidInput(t *testing.T) {
|
||||
// TestAdminBookings_Create_InvalidInput verifies that admin booking
|
||||
// creation fails with HTTP 400 when required fields (userID, startTime, serviceIDs)
|
||||
// are missing or invalid.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -296,7 +301,8 @@ func TestAdminBookings_Create_InvalidInput(t *testing.T) {
|
||||
// Search Admin Bookings Tests
|
||||
// =============================================================================
|
||||
|
||||
func TestAdminBookings_Search(t *testing.T) {
|
||||
// TestAdminBookings_Search tests that an admin can search bookings by
|
||||
// notes, customer name, or other text fields.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -347,7 +353,8 @@ func TestAdminBookings_Search(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminBookings_Search_MissingQuery(t *testing.T) {
|
||||
// TestAdminBookings_Search_MissingQuery verifies that searching without
|
||||
// a query parameter returns HTTP 400 Bad Request.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -369,6 +376,8 @@ func TestAdminBookings_Search_MissingQuery(t *testing.T) {
|
||||
// Get Single Admin Booking Tests
|
||||
// =============================================================================
|
||||
|
||||
// TestAdminBookings_Get verifies that an admin can retrieve a single booking by ID and that
|
||||
// the response includes populated user and services relationships.
|
||||
func TestAdminBookings_Get(t *testing.T) {
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
@@ -422,6 +431,7 @@ func TestAdminBookings_Get(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdminBookings_Get_NotFound verifies that requesting a non-existent booking returns 404.
|
||||
func TestAdminBookings_Get_NotFound(t *testing.T) {
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
@@ -444,6 +454,7 @@ func TestAdminBookings_Get_NotFound(t *testing.T) {
|
||||
// Get User's Bookings Tests (Admin view)
|
||||
// =============================================================================
|
||||
|
||||
// TestAdminBookings_GetUserBookings verifies that an admin can retrieve all bookings for a specific user.
|
||||
func TestAdminBookings_GetUserBookings(t *testing.T) {
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
@@ -503,6 +514,8 @@ func TestAdminBookings_GetUserBookings(t *testing.T) {
|
||||
// Progress Booking Tests
|
||||
// =============================================================================
|
||||
|
||||
// TestAdminBookings_Progress verifies that an admin can change a booking's status (e.g., pending to confirmed),
|
||||
// and that the status is correctly updated in both the response and database.
|
||||
func TestAdminBookings_Progress(t *testing.T) {
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
@@ -562,6 +575,7 @@ func TestAdminBookings_Progress(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdminBookings_Progress_InvalidStatus verifies that providing an invalid status value returns 400 Bad Request.
|
||||
func TestAdminBookings_Progress_InvalidStatus(t *testing.T) {
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
@@ -602,6 +616,7 @@ func TestAdminBookings_Progress_InvalidStatus(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdminBookings_Progress_NotFound verifies that attempting to progress a non-existent booking returns 404.
|
||||
func TestAdminBookings_Progress_NotFound(t *testing.T) {
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
@@ -628,6 +643,7 @@ func TestAdminBookings_Progress_NotFound(t *testing.T) {
|
||||
// Confirm Booking Tests
|
||||
// =============================================================================
|
||||
|
||||
// TestAdminBookings_Confirm verifies that an admin can confirm a pending booking, updating its status to 'confirmed'.
|
||||
func TestAdminBookings_Confirm(t *testing.T) {
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
@@ -675,6 +691,8 @@ func TestAdminBookings_Confirm(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdminBookings_Confirm_AlreadyConfirmed verifies idempotency - attempting to confirm
|
||||
// an already-confirmed booking returns 404 Not Found.
|
||||
func TestAdminBookings_Confirm_AlreadyConfirmed(t *testing.T) {
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
@@ -723,6 +741,7 @@ func TestAdminBookings_Confirm_AlreadyConfirmed(t *testing.T) {
|
||||
// Cancel Booking Tests
|
||||
// =============================================================================
|
||||
|
||||
// TestAdminBookings_Cancel verifies that an admin can cancel a booking, updating its status to 'we_cancelled'.
|
||||
func TestAdminBookings_Cancel(t *testing.T) {
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
@@ -775,6 +794,7 @@ func TestAdminBookings_Cancel(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdminBookings_Cancel_NotFound verifies that attempting to cancel a non-existent booking returns 404.
|
||||
func TestAdminBookings_Cancel_NotFound(t *testing.T) {
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
@@ -797,6 +817,8 @@ func TestAdminBookings_Cancel_NotFound(t *testing.T) {
|
||||
// Non-Admin Tests
|
||||
// =============================================================================
|
||||
|
||||
// TestAdminBookings_NonAdmin verifies that regular users receive 403 Forbidden when attempting
|
||||
// to access any admin booking endpoints (list, get, create, progress, confirm, cancel, search).
|
||||
func TestAdminBookings_NonAdmin(t *testing.T) {
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
@@ -871,6 +893,8 @@ func TestAdminBookings_NonAdmin(t *testing.T) {
|
||||
// Admin Booking Holiday Conflict Tests
|
||||
// =============================================================================
|
||||
|
||||
// TestAdminBookings_Create_DuringHolidayHours_Rejected verifies that an admin cannot create a booking
|
||||
// during hours marked as closed in the exceptional working hours (holiday) system.
|
||||
func TestAdminBookings_Create_DuringHolidayHours_Rejected(t *testing.T) {
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
@@ -953,6 +977,8 @@ func TestAdminBookings_Create_DuringHolidayHours_Rejected(t *testing.T) {
|
||||
// Search Edge Case Tests
|
||||
// =============================================================================
|
||||
|
||||
// TestAdminBookings_Search_CaseInsensitive verifies that the admin booking search is case-insensitive,
|
||||
// matching booking notes regardless of uppercase/lowercase differences.
|
||||
func TestAdminBookings_Search_CaseInsensitive(t *testing.T) {
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
@@ -1016,6 +1042,8 @@ func TestAdminBookings_Search_CaseInsensitive(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdminBookings_Search_NoResults verifies that searching with a query that matches no bookings
|
||||
// returns an empty list with total count of 0.
|
||||
func TestAdminBookings_Search_NoResults(t *testing.T) {
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
@@ -1067,6 +1095,8 @@ func TestAdminBookings_Search_NoResults(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdminBookings_Search_MultipleResults verifies that search returns all bookings whose notes
|
||||
// contain the search query, with correct total count.
|
||||
func TestAdminBookings_Search_MultipleResults(t *testing.T) {
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
@@ -1141,6 +1171,8 @@ func TestAdminBookings_Search_MultipleResults(t *testing.T) {
|
||||
// Admin List Edit Requests Tests
|
||||
// =============================================================================
|
||||
|
||||
// TestAdminBookings_ListEditRequests verifies that an admin can list all pending edit requests
|
||||
// for a specific booking, and that the response includes the correct count and request details.
|
||||
func TestAdminBookings_ListEditRequests(t *testing.T) {
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
@@ -1231,6 +1263,8 @@ func TestAdminBookings_ListEditRequests(t *testing.T) {
|
||||
// Admin Deny Edit Request Tests
|
||||
// =============================================================================
|
||||
|
||||
// TestAdminBookings_DenyEditRequest verifies that denying an edit request deletes the request
|
||||
// while keeping the original booking time unchanged, and returns success.
|
||||
func TestAdminBookings_DenyEditRequest(t *testing.T) {
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
@@ -1334,6 +1368,8 @@ func TestAdminBookings_DenyEditRequest(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdminBookings_ApproveEditRequest verifies that approving an edit request updates the booking's
|
||||
// start_time to the requested time, deletes the edit request, and acknowledges the admin notification.
|
||||
func TestAdminBookings_ApproveEditRequest(t *testing.T) {
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
Reference in New Issue
Block a user