feat(backend): update admin settings and test infrastructure
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -107,7 +107,7 @@ func CreatePatchTest(w http.ResponseWriter, r *http.Request) {
|
|||||||
func UpdatePatchTest(w http.ResponseWriter, r *http.Request) {
|
func UpdatePatchTest(w http.ResponseWriter, r *http.Request) {
|
||||||
id := chi.URLParam(r, "id")
|
id := chi.URLParam(r, "id")
|
||||||
if id == "" || !validators.IsValidID(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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ func UpdatePatchTest(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
_, err := db.DB.Exec(r.Context(), query, args...)
|
_, err := db.DB.Exec(r.Context(), query, args...)
|
||||||
if err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import (
|
|||||||
"crussell/testutils/fixtures"
|
"crussell/testutils/fixtures"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func TestPatchTests_CRUD(t *testing.T) {
|
func TestPatchTests_CRUD(t *testing.T) {
|
||||||
resetTestData(t)
|
resetTestData(t)
|
||||||
|
|
||||||
|
|||||||
@@ -9,17 +9,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type BusinessSettings struct {
|
type BusinessSettings struct {
|
||||||
BusinessName string `json:"business_name"`
|
BusinessName string `json:"business_name"`
|
||||||
BusinessAddress string `json:"business_address"`
|
BusinessAddress string `json:"business_address"`
|
||||||
BusinessPhone *string `json:"business_phone,omitempty"`
|
BusinessPhone *string `json:"business_phone,omitempty"`
|
||||||
BusinessEmail *string `json:"business_email,omitempty"`
|
BusinessEmail *string `json:"business_email,omitempty"`
|
||||||
VATRegistrationNumber *string `json:"vat_registration_number,omitempty"`
|
VATRegistrationNumber *string `json:"vat_registration_number,omitempty"`
|
||||||
IsVATRegistered bool `json:"is_vat_registered"`
|
IsVATRegistered bool `json:"is_vat_registered"`
|
||||||
DefaultVATRate float64 `json:"default_vat_rate"`
|
DefaultVATRate float64 `json:"default_vat_rate"`
|
||||||
CurrencyCode string `json:"currency_code"`
|
CurrencyCode string `json:"currency_code"`
|
||||||
WebsiteURL *string `json:"website_url,omitempty"`
|
WebsiteURL *string `json:"website_url,omitempty"`
|
||||||
GiftCardExpiryMonths int `json:"gift_card_expiry_months"`
|
GiftCardExpiryMonths int `json:"gift_card_expiry_months"`
|
||||||
VoucherType string `json:"voucher_type"`
|
VoucherType string `json:"voucher_type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetBusinessSettings(w http.ResponseWriter, r *http.Request) {
|
func GetBusinessSettings(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import (
|
|||||||
"crussell/db"
|
"crussell/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
func intPtr(i int) *int { return &i }
|
func intPtr(i int) *int { return &i }
|
||||||
func float64Ptr(f float64) *float64 { return &f }
|
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) {
|
func seedBusinessSettings(t *testing.T) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"crussell/db"
|
"crussell/db"
|
||||||
"crussell/testutils/testdb"
|
|
||||||
"crussell/testutils/jwt"
|
"crussell/testutils/jwt"
|
||||||
|
"crussell/testutils/testdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
@@ -23,4 +23,4 @@ func TestMain(m *testing.M) {
|
|||||||
code := m.Run()
|
code := m.Run()
|
||||||
pool.Close()
|
pool.Close()
|
||||||
os.Exit(code)
|
os.Exit(code)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -972,7 +972,7 @@ func TestAdminBookings_UpdateServices_OverlapWithNextBooking(t *testing.T) {
|
|||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
// Booking 1 at 10:00 tomorrow
|
// 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")
|
bookingID1 := createBookingWithStartTime(t, userID, service1, booking1Start, "confirmed")
|
||||||
defer fixtures.DeleteBooking(db.DB, bookingID1)
|
defer fixtures.DeleteBooking(db.DB, bookingID1)
|
||||||
|
|
||||||
@@ -1022,7 +1022,7 @@ func TestAdminBookings_UpdateServices_NoOverlapSucceeds(t *testing.T) {
|
|||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
// Booking 1 at 10:00 tomorrow
|
// 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")
|
bookingID1 := createBookingWithStartTime(t, userID, service1, booking1Start, "confirmed")
|
||||||
defer fixtures.DeleteBooking(db.DB, bookingID1)
|
defer fixtures.DeleteBooking(db.DB, bookingID1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user