From 99e6a019f46bce3ca93c25c7a243e54cbf5a3094 Mon Sep 17 00:00:00 2001 From: Username Date: Sun, 21 Dec 2025 13:45:05 +0100 Subject: [PATCH] tests: fix flaky cleanup test timing for CI --- tests/test_scheduled_cleanup.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/test_scheduled_cleanup.py b/tests/test_scheduled_cleanup.py index 0d05442..058b94b 100644 --- a/tests/test_scheduled_cleanup.py +++ b/tests/test_scheduled_cleanup.py @@ -62,25 +62,26 @@ class TestScheduledCleanup: "/", data="test content", content_type="text/plain", - headers={**auth_header, "X-Expiry": "1"}, # 1 second + headers={**auth_header, "X-Expiry": "2"}, # 2 seconds ) assert response.status_code == 201 paste_id = json.loads(response.data)["id"] - # Wait for expiry - time.sleep(1.5) + # Wait for expiry (extra buffer for CI timing) + time.sleep(3) # Trigger cleanup via database function with app.app_context(): from app.database import cleanup_expired_pastes count = cleanup_expired_pastes() - assert count >= 1 + # At least our paste should be cleaned up + assert count >= 1, f"Expected cleanup to remove at least 1 paste, got {count}" # Verify paste is gone db = get_db() row = db.execute("SELECT id FROM pastes WHERE id = ?", (paste_id,)).fetchone() - assert row is None + assert row is None, f"Paste {paste_id} should have been deleted" def test_rate_limit_cleanup(self, app, client): """Test that rate limit entries are cleaned up."""