1 # Pleroma: A lightweight social networking server
2 # Copyright © 2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.ActivityExpirationTest do
7 alias Pleroma.ActivityExpiration
10 test "finds activities due to be deleted only" do
11 activity = insert(:note_activity)
12 expiration_due = insert(:expiration_in_the_past, %{activity_id: activity.id})
13 activity2 = insert(:note_activity)
14 insert(:expiration_in_the_future, %{activity_id: activity2.id})
16 expirations = ActivityExpiration.due_expirations()
18 assert length(expirations) == 1
19 assert hd(expirations) == expiration_due
22 test "denies expirations that don't live long enough" do
23 activity = insert(:note_activity)
24 now = NaiveDateTime.utc_now()
25 assert {:error, _} = ActivityExpiration.create(activity, now)