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:
@@ -20,6 +20,7 @@ import (
|
||||
"time"
|
||||
|
||||
"crussell/db"
|
||||
"crussell/testutils"
|
||||
"crussell/mw"
|
||||
"crussell/testutils/fixtures"
|
||||
|
||||
@@ -59,7 +60,7 @@ func makeAdminReserveRequest(handler http.Handler, body interface{}, adminID str
|
||||
// create a walk-in reservation with a valid duration. The test verifies
|
||||
// the reservation is created in the database with the correct duration.
|
||||
func TestAdminReserveSlot_WalkIn_Success(t *testing.T) {
|
||||
resetTestData(t)
|
||||
testutils.SetupTestDB(t)
|
||||
|
||||
seedDefaultWorkingHours(t)
|
||||
|
||||
@@ -117,7 +118,7 @@ func TestAdminReserveSlot_WalkIn_Success(t *testing.T) {
|
||||
// create a call-in reservation with valid service IDs. The test verifies
|
||||
// the reservation duration matches the service duration.
|
||||
func TestAdminReserveSlot_CallIn_Success(t *testing.T) {
|
||||
resetTestData(t)
|
||||
testutils.SetupTestDB(t)
|
||||
|
||||
seedDefaultWorkingHours(t)
|
||||
|
||||
@@ -193,7 +194,7 @@ func TestAdminReserveSlot_CallIn_Success(t *testing.T) {
|
||||
// TestAdminReserveSlot_WalkIn_MissingDuration tests that walk-in reservations
|
||||
// fail with HTTP 400 when duration_minutes is missing or zero.
|
||||
func TestAdminReserveSlot_WalkIn_MissingDuration(t *testing.T) {
|
||||
resetTestData(t)
|
||||
testutils.SetupTestDB(t)
|
||||
|
||||
seedDefaultWorkingHours(t)
|
||||
|
||||
@@ -231,7 +232,7 @@ func TestAdminReserveSlot_WalkIn_MissingDuration(t *testing.T) {
|
||||
// TestAdminReserveSlot_CallIn_MissingServices tests that call-in reservations
|
||||
// fail with HTTP 400 when service_ids is empty.
|
||||
func TestAdminReserveSlot_CallIn_MissingServices(t *testing.T) {
|
||||
resetTestData(t)
|
||||
testutils.SetupTestDB(t)
|
||||
|
||||
seedDefaultWorkingHours(t)
|
||||
|
||||
@@ -272,7 +273,7 @@ func TestAdminReserveSlot_CallIn_MissingServices(t *testing.T) {
|
||||
// TestAdminReserveSlot_InvalidReservationType tests that reservations
|
||||
// fail with HTTP 400 when reservation_type is invalid.
|
||||
func TestAdminReserveSlot_InvalidReservationType(t *testing.T) {
|
||||
resetTestData(t)
|
||||
testutils.SetupTestDB(t)
|
||||
|
||||
seedDefaultWorkingHours(t)
|
||||
|
||||
@@ -309,7 +310,7 @@ func TestAdminReserveSlot_InvalidReservationType(t *testing.T) {
|
||||
// TestAdminReserveSlot_SlotOverlap tests that a reservation fails
|
||||
// with HTTP 409 when the slot overlaps with an existing booking.
|
||||
func TestAdminReserveSlot_SlotOverlap(t *testing.T) {
|
||||
resetTestData(t)
|
||||
testutils.SetupTestDB(t)
|
||||
|
||||
seedDefaultWorkingHours(t)
|
||||
|
||||
@@ -381,7 +382,7 @@ func TestAdminReserveSlot_SlotOverlap(t *testing.T) {
|
||||
// TestAdminReserveSlot_ReplacesExisting tests that reserving twice
|
||||
// on the same admin replaces the previous reservation.
|
||||
func TestAdminReserveSlot_ReplacesExisting(t *testing.T) {
|
||||
resetTestData(t)
|
||||
testutils.SetupTestDB(t)
|
||||
|
||||
seedDefaultWorkingHours(t)
|
||||
|
||||
@@ -469,7 +470,7 @@ func TestAdminReserveSlot_ReplacesExisting(t *testing.T) {
|
||||
|
||||
// TestAdminReserveSlot_WalkIn_PastStart tests that walk-in reservations
|
||||
func TestAdminReserveSlot_WalkIn_PastStart(t *testing.T) {
|
||||
resetTestData(t)
|
||||
testutils.SetupTestDB(t)
|
||||
|
||||
seedDefaultWorkingHours(t)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user