Merge branch 'hex-flake-id' into 'develop'
[akkoma] / test / activity_expiration_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.ActivityExpirationTest do
6 use Pleroma.DataCase
7 alias Pleroma.ActivityExpiration
8 import Pleroma.Factory
9
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})
15
16 expirations = ActivityExpiration.due_expirations()
17
18 assert length(expirations) == 1
19 assert hd(expirations) == expiration_due
20 end
21
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)
26 end
27 end