From d16ca4acbe8be6c890732335fb56f1b625db60e9 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sat, 17 Oct 2026 10:32:00 -0400 Subject: [PATCH] fix(tests): scope the sync_queue cleanup wipe to the test devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cleanup in setupSyncTestDB ran DELETE FROM sync_queue WHERE true — a table-wide wipe that discards REAL devices' pending offline entries on every suite run. Same class as the 2026-10-14 reading_history incident the standing rules ban. The test's own queue items cascade from its 'Test %'-named device, so the wipe is redundant for cleanup — scoped it to those devices (defense in depth ahead of the cascade). Flagged during H1 verification: the line executed during an in- container suite run this session; any device with pending offline queue entries at that moment should re-push on its next sync. --- cmd/server/tests/sync_integration_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/server/tests/sync_integration_test.go b/cmd/server/tests/sync_integration_test.go index 6b90f661..f0228c70 100644 --- a/cmd/server/tests/sync_integration_test.go +++ b/cmd/server/tests/sync_integration_test.go @@ -37,7 +37,10 @@ func setupSyncTestDB(t *testing.T) *database.Queries { // 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") + // Same rule for sync_queue: a `WHERE true` wipe could discard a + // REAL device's pending offline entries — scope to the test + // devices (their cascade covers the rest). + _, _ = dbPool.Exec(ctx, "DELETE FROM sync_queue WHERE device_id IN (SELECT id FROM devices WHERE device_name LIKE 'Test %')") _, _ = 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 %'")