From baecc9c8eadd640813cc1233beaaf60097568e93 Mon Sep 17 00:00:00 2001 From: Stephen Adamson Date: Mon, 15 Jun 2026 16:57:42 +0100 Subject: [PATCH] chore: add custom_services and booking_custom_services to test DB cleanup lists Add custom_services and booking_custom_services to testdb dropOrder and TruncateTables lists, and add CreateTestCustomService/DeleteCustomService fixture helpers. Ultraworked with Sisyphus (https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- backend/testutils/fixtures/fixtures.go | 22 ++++++++++++++++++++++ backend/testutils/testdb/testdb.go | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/backend/testutils/fixtures/fixtures.go b/backend/testutils/fixtures/fixtures.go index 003b56c..dadcc02 100644 --- a/backend/testutils/fixtures/fixtures.go +++ b/backend/testutils/fixtures/fixtures.go @@ -193,6 +193,28 @@ func DeleteBooking(pool *pgxpool.Pool, bookingID string) error { return err } +func CreateTestCustomService(pool *pgxpool.Pool) (string, error) { + ctx := context.Background() + var serviceID string + err := pool.QueryRow(ctx, ` + INSERT INTO custom_services (name, description, price, duration_minutes, minimum_age_required) + VALUES ($1, $2, $3, $4, $5) + RETURNING id + `, "Test Custom Service", "A test custom service", 75.00, 45, 16).Scan(&serviceID) + + if err != nil { + return "", fmt.Errorf("failed to create custom service: %w", err) + } + + return serviceID, nil +} + +func DeleteCustomService(pool *pgxpool.Pool, serviceID string) error { + ctx := context.Background() + _, err := pool.Exec(ctx, "DELETE FROM custom_services WHERE id = $1", serviceID) + return err +} + // SafeDeleteUser wraps DeleteUser and returns error (for tests that care about cleanup failure) func SafeDeleteUser(db *pgxpool.Pool, userID string) error { return DeleteUser(db, userID) diff --git a/backend/testutils/testdb/testdb.go b/backend/testutils/testdb/testdb.go index b2e1957..83838b7 100644 --- a/backend/testutils/testdb/testdb.go +++ b/backend/testutils/testdb/testdb.go @@ -113,6 +113,7 @@ func Migrate(t *testing.T, pool *pgxpool.Pool) { "admin_notifications", "user_notification_preferences", "user_referrals", + "booking_custom_services", "booking_services", "refunds", "payments", @@ -127,6 +128,7 @@ func Migrate(t *testing.T, pool *pgxpool.Pool) { "patch_tests", "booking_edit_requests", "services", + "custom_services", "verification_codes", "user_social_logins", "users", @@ -282,6 +284,7 @@ func TruncateTables(t *testing.T, pool *pgxpool.Pool) { "forgiven_no_shows", "user_social_logins", "verification_codes", + "booking_custom_services", "booking_services", "refunds", "payments", @@ -296,6 +299,7 @@ func TruncateTables(t *testing.T, pool *pgxpool.Pool) { "user_patch_tests", "patch_tests", "services", + "custom_services", "admin_notifications", "user_referrals", "user_notification_preferences",