Run initial retention checks regardless of host uptime

This commit is contained in:
Pigway
2026-10-10 01:35:32 +08:00
parent 7d10d5b601
commit 4fdb7a4407
4 changed files with 24 additions and 3 deletions
+21
View File
@@ -151,3 +151,24 @@ def test_cleanup_option_requires_random_photo_job():
source={"type": "template", "template": "quote"},
cleanup_unstarred=True,
)
def test_first_cleanup_runs_after_recent_host_boot(
client, service, settings, monkeypatch
):
image_id = upload_random(client, service, settings)
due(service, image_id)
monkeypatch.setattr(
"pigway_frame_flow.display.retention.time.monotonic", lambda: 120
)
service.retention.sweep()
row = service.db.one("SELECT * FROM image_retention WHERE image_id=?", (image_id,))
assert row["cleanup_operation"]
assert service.retention.checked == 120
service.retention.sweep()
assert (
service.db.one("SELECT COUNT(*) AS n FROM operations WHERE action='delete'")[
"n"
]
== 1
)