From 3582965492bba8d451f1f3a2f8105dc721b1c691 Mon Sep 17 00:00:00 2001 From: Stephen Adamson Date: Thu, 18 Jun 2026 16:26:12 +0100 Subject: [PATCH] feat(backend): update admin settings and test infrastructure Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- backend/handlers/admin/patch_tests.go | 4 ++-- backend/handlers/admin/patch_tests_test.go | 1 - backend/handlers/admin/settings.go | 22 +++++++++---------- backend/handlers/admin/settings_test.go | 4 ++-- backend/handlers/admin/testmain_test.go | 4 ++-- .../admin/update_booking_services_test.go | 4 ++-- 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/backend/handlers/admin/patch_tests.go b/backend/handlers/admin/patch_tests.go index 342177f..2035990 100644 --- a/backend/handlers/admin/patch_tests.go +++ b/backend/handlers/admin/patch_tests.go @@ -107,7 +107,7 @@ func CreatePatchTest(w http.ResponseWriter, r *http.Request) { func UpdatePatchTest(w http.ResponseWriter, r *http.Request) { id := chi.URLParam(r, "id") if id == "" || !validators.IsValidID(id) { - http.Error(w, "Patch test not found (ID: " + id + ")", http.StatusNotFound) + http.Error(w, "Patch test not found", http.StatusNotFound) return } @@ -158,7 +158,7 @@ func UpdatePatchTest(w http.ResponseWriter, r *http.Request) { _, err := db.DB.Exec(r.Context(), query, args...) if err != nil { - http.Error(w, "Failed to update patch test: " + err.Error() + " Query: " + query, http.StatusInternalServerError) + http.Error(w, "Failed to update patch test", http.StatusInternalServerError) return } diff --git a/backend/handlers/admin/patch_tests_test.go b/backend/handlers/admin/patch_tests_test.go index 4892026..f52c559 100644 --- a/backend/handlers/admin/patch_tests_test.go +++ b/backend/handlers/admin/patch_tests_test.go @@ -11,7 +11,6 @@ import ( "crussell/testutils/fixtures" ) - func TestPatchTests_CRUD(t *testing.T) { resetTestData(t) diff --git a/backend/handlers/admin/settings.go b/backend/handlers/admin/settings.go index 99505af..e2a0510 100644 --- a/backend/handlers/admin/settings.go +++ b/backend/handlers/admin/settings.go @@ -9,17 +9,17 @@ import ( ) type BusinessSettings struct { - BusinessName string `json:"business_name"` - BusinessAddress string `json:"business_address"` - BusinessPhone *string `json:"business_phone,omitempty"` - BusinessEmail *string `json:"business_email,omitempty"` - VATRegistrationNumber *string `json:"vat_registration_number,omitempty"` - IsVATRegistered bool `json:"is_vat_registered"` - DefaultVATRate float64 `json:"default_vat_rate"` - CurrencyCode string `json:"currency_code"` - WebsiteURL *string `json:"website_url,omitempty"` - GiftCardExpiryMonths int `json:"gift_card_expiry_months"` - VoucherType string `json:"voucher_type"` + BusinessName string `json:"business_name"` + BusinessAddress string `json:"business_address"` + BusinessPhone *string `json:"business_phone,omitempty"` + BusinessEmail *string `json:"business_email,omitempty"` + VATRegistrationNumber *string `json:"vat_registration_number,omitempty"` + IsVATRegistered bool `json:"is_vat_registered"` + DefaultVATRate float64 `json:"default_vat_rate"` + CurrencyCode string `json:"currency_code"` + WebsiteURL *string `json:"website_url,omitempty"` + GiftCardExpiryMonths int `json:"gift_card_expiry_months"` + VoucherType string `json:"voucher_type"` } func GetBusinessSettings(w http.ResponseWriter, r *http.Request) { diff --git a/backend/handlers/admin/settings_test.go b/backend/handlers/admin/settings_test.go index ec192ad..c06a628 100644 --- a/backend/handlers/admin/settings_test.go +++ b/backend/handlers/admin/settings_test.go @@ -11,9 +11,9 @@ import ( "crussell/db" ) -func intPtr(i int) *int { return &i } +func intPtr(i int) *int { return &i } func float64Ptr(f float64) *float64 { return &f } -func boolPtr(b bool) *bool { return &b } +func boolPtr(b bool) *bool { return &b } func seedBusinessSettings(t *testing.T) { t.Helper() diff --git a/backend/handlers/admin/testmain_test.go b/backend/handlers/admin/testmain_test.go index 15209a7..c667c3c 100644 --- a/backend/handlers/admin/testmain_test.go +++ b/backend/handlers/admin/testmain_test.go @@ -8,8 +8,8 @@ import ( "testing" "crussell/db" - "crussell/testutils/testdb" "crussell/testutils/jwt" + "crussell/testutils/testdb" ) func TestMain(m *testing.M) { @@ -23,4 +23,4 @@ func TestMain(m *testing.M) { code := m.Run() pool.Close() os.Exit(code) -} \ No newline at end of file +} diff --git a/backend/handlers/admin/update_booking_services_test.go b/backend/handlers/admin/update_booking_services_test.go index 428f739..4348d7e 100644 --- a/backend/handlers/admin/update_booking_services_test.go +++ b/backend/handlers/admin/update_booking_services_test.go @@ -972,7 +972,7 @@ func TestAdminBookings_UpdateServices_OverlapWithNextBooking(t *testing.T) { now := time.Now() // Booking 1 at 10:00 tomorrow - booking1Start := now.Add(24*time.Hour).Truncate(24*time.Hour).Add(10 * time.Hour) + booking1Start := now.Add(24 * time.Hour).Truncate(24 * time.Hour).Add(10 * time.Hour) bookingID1 := createBookingWithStartTime(t, userID, service1, booking1Start, "confirmed") defer fixtures.DeleteBooking(db.DB, bookingID1) @@ -1022,7 +1022,7 @@ func TestAdminBookings_UpdateServices_NoOverlapSucceeds(t *testing.T) { now := time.Now() // Booking 1 at 10:00 tomorrow - booking1Start := now.Add(24*time.Hour).Truncate(24*time.Hour).Add(10 * time.Hour) + booking1Start := now.Add(24 * time.Hour).Truncate(24 * time.Hour).Add(10 * time.Hour) bookingID1 := createBookingWithStartTime(t, userID, service1, booking1Start, "confirmed") defer fixtures.DeleteBooking(db.DB, bookingID1)