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
+21 -6
View File
@@ -74,15 +74,21 @@ func TestDevClient_CreateCheckout_PendingThenCompleted(t *testing.T) {
t.Error("expected checkout ID to be set")
}
time.Sleep(4 * time.Second)
completed, err := client.GetCheckout(ctx, result.ID)
// Poll until the background goroutine completes — avoids any timing assumptions
var completed *PaymentResult
for i := 0; i < 20; i++ {
completed, err = client.GetCheckout(ctx, result.ID)
if err == nil && completed.Status == "COMPLETED" {
break
}
time.Sleep(5 * time.Millisecond)
}
if err != nil {
t.Fatalf("GetCheckout failed: %v", err)
}
if completed.Status != "COMPLETED" {
t.Errorf("expected status COMPLETED after wait, got %s", completed.Status)
t.Errorf("expected status COMPLETED, got %s", completed.Status)
}
if completed.Amount != 8000 {
@@ -115,9 +121,18 @@ func TestDevClient_CreateCheckout_NoTip(t *testing.T) {
t.Errorf("expected status PENDING, got %s", result.Status)
}
time.Sleep(4 * time.Second)
if result.ID == "" {
t.Error("expected checkout ID to be set")
}
completed, err := client.GetCheckout(ctx, result.ID)
var completed *PaymentResult
for i := 0; i < 20; i++ {
completed, err = client.GetCheckout(ctx, result.ID)
if err == nil && completed.Status == "COMPLETED" {
break
}
time.Sleep(5 * time.Millisecond)
}
if err != nil {
t.Fatalf("GetCheckout failed: %v", err)
}