Merge branch 'develop' into issue/1383
[akkoma] / test / workers / cron / purge_expired_activities_worker_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Workers.Cron.PurgeExpiredActivitiesWorkerTest do
6 use Pleroma.DataCase
7 alias Pleroma.ActivityExpiration
8 import Pleroma.Factory
9
10 clear_config([ActivityExpiration, :enabled])
11
12 test "deletes an expiration activity" do
13 Pleroma.Config.put([ActivityExpiration, :enabled], true)
14 activity = insert(:note_activity)
15
16 naive_datetime =
17 NaiveDateTime.add(
18 NaiveDateTime.utc_now(),
19 -:timer.minutes(2),
20 :millisecond
21 )
22
23 expiration =
24 insert(
25 :expiration_in_the_past,
26 %{activity_id: activity.id, scheduled_at: naive_datetime}
27 )
28
29 Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker.perform(:ops, :pid)
30
31 refute Pleroma.Repo.get(Pleroma.Activity, activity.id)
32 refute Pleroma.Repo.get(Pleroma.ActivityExpiration, expiration.id)
33 end
34 end