tests: fix flaky cleanup test timing for CI
All checks were successful
CI / Lint & Format (push) Successful in 17s
CI / Security Scan (push) Successful in 21s
CI / Tests (push) Successful in 1m2s

This commit is contained in:
Username
2025-12-21 13:45:05 +01:00
parent 2ccbfcbfaa
commit 99e6a019f4

View File

@@ -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."""