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()
|
||||
|
||||
@@ -27,7 +27,9 @@ import (
|
||||
"crussell/mw"
|
||||
)
|
||||
|
||||
func TestAdminServices_Create(t *testing.T) {
|
||||
// TestAdminServices_Create verifies that an admin can create a new service
|
||||
// with name, description, price, duration, and minimum age requirements. The new
|
||||
// service is active by default and stored in the database.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -72,7 +74,8 @@ func TestAdminServices_Create(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminServices_List(t *testing.T) {
|
||||
// TestAdminServices_List tests that an admin can retrieve all services,
|
||||
// including inactive ones. This is useful for managing the full service catalog.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -121,7 +124,9 @@ func TestAdminServices_List(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminServices_Toggle(t *testing.T) {
|
||||
// TestAdminServices_Toggle verifies that an admin can toggle a service's
|
||||
// active status on/off. This is used to temporarily disable a service without
|
||||
// deleting it from the system.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -169,7 +174,9 @@ func TestAdminServices_Toggle(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminServices_Delete(t *testing.T) {
|
||||
// TestAdminServices_Delete tests that an admin can soft-delete a service
|
||||
// by setting is_active to false. The service record remains but is hidden from
|
||||
// customers.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -202,7 +209,9 @@ func TestAdminServices_Delete(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminServices_NonAdmin(t *testing.T) {
|
||||
// TestAdminServices_NonAdmin verifies that non-admin users receive HTTP 403
|
||||
// Forbidden when attempting to create, list, toggle, or delete services. This
|
||||
// ensures proper role-based access control.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ import (
|
||||
"crussell/mw"
|
||||
)
|
||||
|
||||
func TestAdminToday_CurrentNext(t *testing.T) {
|
||||
// TestAdminToday_CurrentNext verifies that an admin can retrieve the currently
|
||||
// in-progress booking and the next upcoming booking for the dashboard.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -104,7 +105,8 @@ func TestAdminToday_CurrentNext(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminToday_Appointments(t *testing.T) {
|
||||
// TestAdminToday_Appointments tests that an admin can get a list of all
|
||||
// bookings scheduled for today with their details.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -178,7 +180,8 @@ func TestAdminToday_Appointments(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminToday_PendingApprovals(t *testing.T) {
|
||||
// TestAdminToday_PendingApprovals verifies that an admin can see all pending
|
||||
// bookings that require approval/confirmation.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -252,15 +255,18 @@ func TestAdminToday_PendingApprovals(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminNotifications_List(t *testing.T) {
|
||||
// TestAdminNotifications_List is skipped (WIP) - tests that an admin
|
||||
// can list all their notifications.
|
||||
t.Skip("Skipping - WIP handler")
|
||||
}
|
||||
|
||||
func TestAdminNotifications_Acknowledge(t *testing.T) {
|
||||
// TestAdminNotifications_Acknowledge is skipped (WIP) - tests that an
|
||||
// admin can acknowledge a notification.
|
||||
t.Skip("Skipping - WIP handler")
|
||||
}
|
||||
|
||||
func TestAdminToday_NonAdmin(t *testing.T) {
|
||||
// TestAdminToday_NonAdmin verifies that non-admin users receive HTTP 403
|
||||
// when accessing today's dashboard endpoints.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ import (
|
||||
"crussell/mw"
|
||||
)
|
||||
|
||||
func TestAdminUsers_List(t *testing.T) {
|
||||
// TestAdminUsers_List verifies that an admin can list all users in the
|
||||
// system with their details including account role and type.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -65,7 +66,8 @@ func TestAdminUsers_List(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminUsers_Get(t *testing.T) {
|
||||
// TestAdminUsers_Get tests that an admin can retrieve detailed information
|
||||
// about a specific user including their profile and account settings.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -101,7 +103,8 @@ func TestAdminUsers_Get(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminUsers_Get_NotFound(t *testing.T) {
|
||||
// TestAdminUsers_Get_NotFound verifies that requesting details for a
|
||||
// non-existent user returns HTTP 404 Not Found.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -114,7 +117,9 @@ func TestAdminUsers_Get_NotFound(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminUsers_PatchTests_Eligible(t *testing.T) {
|
||||
// TestAdminUsers_PatchTests_Eligible tests that the system correctly
|
||||
// identifies which services require patch tests and returns only those services
|
||||
// the user is eligible for based on age requirements.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -188,7 +193,9 @@ func TestAdminUsers_PatchTests_Eligible(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminUsers_PatchTests_Eligible_WithExisting(t *testing.T) {
|
||||
// TestAdminUsers_PatchTests_Eligible_WithExisting verifies that when a
|
||||
// user already has a valid patch test on file, that service is filtered out
|
||||
// from the eligible list (since they've already completed it).
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -273,7 +280,8 @@ func TestAdminUsers_PatchTests_Eligible_WithExisting(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminUsers_AddPatchTest(t *testing.T) {
|
||||
// TestAdminUsers_AddPatchTest verifies that an admin can record a patch
|
||||
// test completion for a user, creating a user_patch_tests record.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -359,7 +367,8 @@ func TestAdminUsers_AddPatchTest_InvalidPatchTest(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminUsers_NonAdmin(t *testing.T) {
|
||||
// TestAdminUsers_NonAdmin verifies that non-admin users receive HTTP 403
|
||||
// Forbidden when attempting to list users, get user details, or manage patch tests.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
@@ -414,7 +423,8 @@ func TestAdminUsers_NonAdmin(t *testing.T) {
|
||||
|
||||
|
||||
|
||||
func TestAdminUsers_Get_Success(t *testing.T) {
|
||||
// TestAdminUsers_Get_Success is an additional test verifying admin can
|
||||
// retrieve user details including ID, name, email, and account role.
|
||||
cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user