1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Workers.Cron.PurgeExpiredActivitiesWorkerTest do
8 alias Pleroma.ActivityExpiration
9 alias Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker
11 import Pleroma.Factory
12 import ExUnit.CaptureLog
14 clear_config([ActivityExpiration, :enabled])
16 test "deletes an expiration activity" do
17 Pleroma.Config.put([ActivityExpiration, :enabled], true)
18 activity = insert(:note_activity)
22 NaiveDateTime.utc_now(),
29 :expiration_in_the_past,
30 %{activity_id: activity.id, scheduled_at: naive_datetime}
33 Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker.perform(:ops, :pid)
35 refute Pleroma.Repo.get(Pleroma.Activity, activity.id)
36 refute Pleroma.Repo.get(Pleroma.ActivityExpiration, expiration.id)
39 describe "delete_activity/1" do
40 test "adds log message if activity isn't find" do
41 assert capture_log([level: :error], fn ->
42 PurgeExpiredActivitiesWorker.delete_activity(%ActivityExpiration{
43 activity_id: "test-activity"
45 end) =~ "Couldn't delete expired activity: not found activity"
48 test "adds log message if actor isn't find" do
49 assert capture_log([level: :error], fn ->
50 PurgeExpiredActivitiesWorker.delete_activity(%ActivityExpiration{
51 activity_id: "test-activity"
53 end) =~ "Couldn't delete expired activity: not found activity"