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:
@@ -189,3 +189,74 @@ func TestParseCursor_EmptyCursor(t *testing.T) {
|
||||
t.Fatal("expected error for empty cursor, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseCursor3_Valid(t *testing.T) {
|
||||
count, tm, id, err := ParseCursor3("5|2026-06-15T10:30:00Z|abc123def456")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if count != 5 {
|
||||
t.Errorf("expected count 5, got %d", count)
|
||||
}
|
||||
if tm.Year() != 2026 || tm.Month() != 6 || tm.Day() != 15 {
|
||||
t.Errorf("unexpected time: %v", tm)
|
||||
}
|
||||
if id != "abc123def456" {
|
||||
t.Errorf("expected id 'abc123def456', got %q", id)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseCursor3_InvalidFormat(t *testing.T) {
|
||||
_, _, _, err := ParseCursor3("not-a-valid-cursor")
|
||||
if err == nil {
|
||||
t.Fatal("expected error for invalid cursor format, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseCursor3_InvalidCount(t *testing.T) {
|
||||
_, _, _, err := ParseCursor3("not-a-number|2026-06-15T10:30:00Z|abc123def456")
|
||||
if err == nil {
|
||||
t.Fatal("expected error for invalid count, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseCursor3_InvalidTimestamp(t *testing.T) {
|
||||
_, _, _, err := ParseCursor3("5|not-a-time|abc123def456")
|
||||
if err == nil {
|
||||
t.Fatal("expected error for invalid timestamp, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseCursor3_EmptyCursor(t *testing.T) {
|
||||
_, _, _, err := ParseCursor3("")
|
||||
if err == nil {
|
||||
t.Fatal("expected error for empty cursor, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseCursor3_ZeroCount(t *testing.T) {
|
||||
count, _, _, err := ParseCursor3("0|2026-06-15T10:30:00Z|abc123def456")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if count != 0 {
|
||||
t.Errorf("expected count 0, got %d", count)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseCursor3_LargeCount(t *testing.T) {
|
||||
count, _, _, err := ParseCursor3("999|2026-06-15T10:30:00Z|abc123def456")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if count != 999 {
|
||||
t.Errorf("expected count 999, got %d", count)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseCursor3_NegativeCount(t *testing.T) {
|
||||
_, _, _, err := ParseCursor3("-1|2026-06-15T10:30:00Z|abc123def456")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error for negative count: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user