diff --git a/AGENTS.md b/AGENTS.md index 747a9dc5..60819108 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -53,7 +53,10 @@ were name-only across ALL libraries. Fixed; do not regress. broke on 2026-10-14 within hours of session capture shipping). Tests that need deterministic data use `setup.RegularToken` + `getRegularUserID` (the fresh per-test user), or assert ranges - instead of equals. + instead of equals. Related: **no table-wide DELETEs in test + cleanups** — sync_integration's `DELETE FROM reading_history WHERE + true` destroyed the live reader's stats data on every suite run + until scoped to the test-sync users (cascade via user delete). ## Timezones diff --git a/cmd/server/tests/sync_integration_test.go b/cmd/server/tests/sync_integration_test.go index 9b49c8a0..6b90f661 100644 --- a/cmd/server/tests/sync_integration_test.go +++ b/cmd/server/tests/sync_integration_test.go @@ -32,12 +32,16 @@ func setupSyncTestDB(t *testing.T) *database.Queries { db := database.New(dbPool) t.Cleanup(func() { + // Scoped wipes ONLY: reading_history now carries real captured + // sessions for the shared dev accounts, so a table-wide DELETE + // here silently destroyed a live reader's stats data on every + // suite run (2026-10-14). Sync-test sessions belong to the + // test-sync users; deleting those users cascades their rows. _, _ = dbPool.Exec(ctx, "DELETE FROM sync_queue WHERE true") - _, _ = dbPool.Exec(ctx, "DELETE FROM reading_history WHERE true") + _, _ = dbPool.Exec(ctx, "DELETE FROM users WHERE email LIKE 'test-sync%'") _, _ = dbPool.Exec(ctx, "DELETE FROM media_items WHERE title LIKE 'Test %'") _, _ = dbPool.Exec(ctx, "DELETE FROM libraries WHERE name LIKE 'Test %'") _, _ = dbPool.Exec(ctx, "DELETE FROM devices WHERE device_name LIKE 'Test %'") - _, _ = dbPool.Exec(ctx, "DELETE FROM users WHERE email LIKE 'test-sync%'") dbPool.Close() })