akkoma/test/pleroma/object/pruner_test.exs
floatingghost db60640c5b Fixing up deletes a bit (#327)
Co-authored-by: FloatingGhost <hannah@coffee-and-dreams.uk>
Reviewed-on: AkkomaGang/akkoma#327
2022-12-01 15:00:53 +00:00

41 lines
1 KiB
Elixir

defmodule Pleroma.Object.PrunerTest do
use Pleroma.DataCase, async: true
alias Pleroma.Delivery
alias Pleroma.Object
alias Pleroma.Object.Pruner
import Pleroma.Factory
describe "prune_deletes" do
test "it prunes old delete objects" do
new_tombstone = insert(:tombstone)
old_tombstone =
insert(:tombstone,
inserted_at: DateTime.utc_now() |> DateTime.add(-31 * 24, :hour)
)
Pruner.prune_tombstones()
assert Object.get_by_id(new_tombstone.id)
refute Object.get_by_id(old_tombstone.id)
end
end
describe "prune_tombstoned_deliveries" do
test "it prunes old tombstone deliveries" do
user = insert(:user)
tombstone = insert(:tombstone)
tombstoned = insert(:delivery, object: tombstone, user: user)
note = insert(:note)
not_tombstoned = insert(:delivery, object: note, user: user)
Pruner.prune_tombstoned_deliveries()
refute Repo.get(Delivery, tombstoned.id)
assert Repo.get(Delivery, not_tombstoned.id)
end
end
end