refactor(backend): replace resetTestData with SetupTestDB and add new tests

Migrate all test files from resetTestData(t) to testutils.SetupTestDB(t) for isolated per-package test databases.

- Add new feature tests: name history assertions, referral discount preview,
  time blockers, email validation, GDPR export, loyalty manual redemption
- Update existing tests to use batch queries and SetupTestDB
- Remove test_helpers.go resetTestData infrastructure
- Add comprehensive user profile tests (442 new lines)

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-06-20 16:57:36 +01:00
co-authored by Sisyphus
parent 9c68918c20
commit b03c4f6247
36 changed files with 1735 additions and 859 deletions
@@ -10,13 +10,14 @@ import (
"time"
"crussell/db"
"crussell/testutils"
"crussell/handlers/bookings"
"crussell/testutils/fixtures"
)
// TestGetOverlappingBookingsByTime verifies the new overlapping bookings endpoint
func TestGetOverlappingBookingsByTime(t *testing.T) {
resetTestData(t)
testutils.SetupTestDB(t)
adminID, err := fixtures.CreateTestAdminUser(db.DB)
if err != nil {
@@ -62,7 +63,7 @@ func TestGetOverlappingBookingsByTime(t *testing.T) {
// TestGetBookingsByDateRange verifies the new bookings by date range endpoint
func TestGetBookingsByDateRange(t *testing.T) {
resetTestData(t)
testutils.SetupTestDB(t)
adminID, err := fixtures.CreateTestAdminUser(db.DB)
if err != nil {
@@ -108,7 +109,7 @@ func TestGetBookingsByDateRange(t *testing.T) {
// TestAdminRescheduleBooking verifies the new reschedule endpoint
func TestAdminRescheduleBooking(t *testing.T) {
resetTestData(t)
testutils.SetupTestDB(t)
adminID, err := fixtures.CreateTestAdminUser(db.DB)
if err != nil {