Tests: removing old and over-quota downloads #396
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
retention.rs is at 59% of its lines with both suites together, and what is untested is the part that deletes files:
run's age and quota passes (lines 79-97) andremove(104-119), which deletes the file, marks it reaped and counts the bytes freed. The pure choosers (aged,pick) have tests; nothing runs them against files and a database. A mistake here deletes someone's downloads.Tests to add (cargo, against a scratch data directory):
max_age_daysis deleted from disk, marked reaped, and its bytes counted; one newer is leftmax_total_gb, the oldest go first until under, and what the age pass took is not counted twiceSeen with the coverage of both suites merged line by line (cargo:
sh scripts/coverage.sh, browser:sh scripts/coverage.sh api; reports in target/coverage/cargo, api and page; #390, #394), as of 2026-11-07. A test added here shows in Grafana's Coverage row at the next run.Tests added in
a92e81a(retention.rs): the age pass deletes, marks reaped, counts bytes and prunes entries, and a dry run does none of it but counts the same; over quota the oldest go first and the age pass's take is not counted twice; a missing file is reaped without an error and one that cannot be unlinked (/proc/version) is left unreaped with nothing counted; held items are never candidates. Pass on SQLite and Postgres. Kept (starred) items were already covered by query_never_offers_a_file_anyone_starred...