[Bugfix] Fix off-by-1 error for retention date logic (#432)

* Added a sanity check test to the media context

* Improves logic for handing media item culling dates
This commit is contained in:
Kieran
2024-10-24 10:26:30 -07:00
committed by GitHub
parent cae86953a0
commit 3c8d99196a
4 changed files with 48 additions and 20 deletions
+7
View File
@@ -441,6 +441,13 @@ defmodule Pinchflat.MediaTest do
assert Media.pending_download?(media_item)
end
test "returns true if the cutoff date is equal to the upload date" do
source = source_fixture(%{download_cutoff_date: now_minus(2, :days)})
media_item = media_item_fixture(%{source_id: source.id, media_filepath: nil, uploaded_at: now_minus(2, :days)})
assert Media.pending_download?(media_item)
end
test "returns false if there is a cutoff date after the media's upload date" do
source = source_fixture(%{download_cutoff_date: now_minus(1, :day)})
media_item = media_item_fixture(%{source_id: source.id, media_filepath: nil, uploaded_at: now_minus(2, :days)})