Migrate all test files from SetupTestDB/db.DB pattern to per-test transactions:
- Replace SetupTestDB(t) with SetupTestTx(t) for context + transaction
- Replace db.DB.Query/QueryRow/Exec with tx.Query/QueryRow/Exec
- Replace context.Background() with context from SetupTestTx
- Replace defer rows.Close() pattern with explicit rows.Close()
- Add testdb.SeedBaseline(pool) to all TestMain functions
- Wire db.Conn = db.NewPoolProxy(pool) in all TestMain functions
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
- Add TestMain to all 10 test packages (schema DROP+CREATE runs once per package)
- Convert per-test setupTestDB to resetTestData (TRUNCATE only, ~60% faster)
- Add 3 missing tables to TruncateTables (booking_edit_requests, exceptional_group_applications, business_settings)
- Remove dead truncateDiscountTables helper
- Consolidate discount_test.go into package bookings (was external test package)
- Update testutils.SetupTestDB to truncate-only
- Fix unused imports across user, bookings, and handlers packages
- Verify: 286 passing, 2 skipped, 0 failures with -count=2 (no state leakage)
- Add TestMain to set test env vars and testdb.TruncateTables for test
isolation
- Add chi routing context to test helpers for path parameter extraction
- Fix SQL error handling to use errors.Is() instead of ==
- Add validators package with ID validation
- Fix admin test middleware chain (RequireAdmin wrapper)
- Update test user inserts to include phone and date_of_birth fields
- Update service delete test to check soft-delete (is_active=false)
- Update holiday hours test to use new schema (weekday, is_open)
- Add phone number validation tests for UK mobile numbers
- RequireAdmin needs RequireAuth to populate context first
- Add mw.RequireAuth wrapper to all NonAdmin test middleware chains
- Tests now properly validate auth before checking admin role
- Tests passing: 30/33 (up from 24/27)
- Remaining failures are handler bugs, not test setup issues
- Database returns HH:MM:SS format, tests expected HH:MM
- Fix assertions in TestScheduling_GetDefaultHours and TestScheduling_UpdateDefaultHours_Admin
- Tests now pass: 24/27 (up from 18/27)
- Remaining failures are real test logic issues
- Add explicit verification loop in local-dev-2.sh to wait for crussell_test database to be ready before running tests (prevents race condition)
- Remove unused 'handler' variable declaration in scheduling_test.go that was breaking the build
- Tests now properly execute without immediate 'database does not exist' errors
- Real test failures are now visible instead of being masked by setup issues
- Create crussell_test database after PostgreSQL reset
- Seed test DB schema from init-script.sql so tests can run
- This fixes the TLS connection errors in test runs
Also:
- Fixed color variables in script (C_RESET, C_GREEN, etc.)