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 <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -193,6 +193,28 @@ func DeleteBooking(pool *pgxpool.Pool, bookingID string) error {
|
|||||||
return err
|
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)
|
// SafeDeleteUser wraps DeleteUser and returns error (for tests that care about cleanup failure)
|
||||||
func SafeDeleteUser(db *pgxpool.Pool, userID string) error {
|
func SafeDeleteUser(db *pgxpool.Pool, userID string) error {
|
||||||
return DeleteUser(db, userID)
|
return DeleteUser(db, userID)
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ func Migrate(t *testing.T, pool *pgxpool.Pool) {
|
|||||||
"admin_notifications",
|
"admin_notifications",
|
||||||
"user_notification_preferences",
|
"user_notification_preferences",
|
||||||
"user_referrals",
|
"user_referrals",
|
||||||
|
"booking_custom_services",
|
||||||
"booking_services",
|
"booking_services",
|
||||||
"refunds",
|
"refunds",
|
||||||
"payments",
|
"payments",
|
||||||
@@ -127,6 +128,7 @@ func Migrate(t *testing.T, pool *pgxpool.Pool) {
|
|||||||
"patch_tests",
|
"patch_tests",
|
||||||
"booking_edit_requests",
|
"booking_edit_requests",
|
||||||
"services",
|
"services",
|
||||||
|
"custom_services",
|
||||||
"verification_codes",
|
"verification_codes",
|
||||||
"user_social_logins",
|
"user_social_logins",
|
||||||
"users",
|
"users",
|
||||||
@@ -282,6 +284,7 @@ func TruncateTables(t *testing.T, pool *pgxpool.Pool) {
|
|||||||
"forgiven_no_shows",
|
"forgiven_no_shows",
|
||||||
"user_social_logins",
|
"user_social_logins",
|
||||||
"verification_codes",
|
"verification_codes",
|
||||||
|
"booking_custom_services",
|
||||||
"booking_services",
|
"booking_services",
|
||||||
"refunds",
|
"refunds",
|
||||||
"payments",
|
"payments",
|
||||||
@@ -296,6 +299,7 @@ func TruncateTables(t *testing.T, pool *pgxpool.Pool) {
|
|||||||
"user_patch_tests",
|
"user_patch_tests",
|
||||||
"patch_tests",
|
"patch_tests",
|
||||||
"services",
|
"services",
|
||||||
|
"custom_services",
|
||||||
"admin_notifications",
|
"admin_notifications",
|
||||||
"user_referrals",
|
"user_referrals",
|
||||||
"user_notification_preferences",
|
"user_notification_preferences",
|
||||||
|
|||||||
Reference in New Issue
Block a user