forked from username/flaskpaste
tests: fix flaky cleanup test timing for CI
This commit is contained in:
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user