1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Workers.PurgeExpiredActivityTest do
6 use Pleroma.DataCase, async: true
7 use Oban.Testing, repo: Pleroma.Repo
11 alias Pleroma.Workers.PurgeExpiredActivity
14 activity = insert(:note_activity)
17 PurgeExpiredActivity.enqueue(%{
18 activity_id: activity.id,
19 expires_at: DateTime.add(DateTime.utc_now(), 3601)
23 worker: Pleroma.Workers.PurgeExpiredActivity,
24 args: %{activity_id: activity.id}
28 perform_job(Pleroma.Workers.PurgeExpiredActivity, %{activity_id: activity.id})
30 assert %Oban.Job{} = Pleroma.Workers.PurgeExpiredActivity.get_expiration(activity.id)
33 test "error if user was not found" do
34 activity = insert(:note_activity)
37 PurgeExpiredActivity.enqueue(%{
38 activity_id: activity.id,
39 expires_at: DateTime.add(DateTime.utc_now(), 3601)
42 user = Pleroma.User.get_by_ap_id(activity.actor)
43 Pleroma.Repo.delete(user)
45 assert {:error, :user_not_found} =
46 perform_job(Pleroma.Workers.PurgeExpiredActivity, %{activity_id: activity.id})
49 test "error if actiivity was not found" do
51 PurgeExpiredActivity.enqueue(%{
52 activity_id: "some_id",
53 expires_at: DateTime.add(DateTime.utc_now(), 3601)
56 assert {:error, :activity_not_found} =
57 perform_job(Pleroma.Workers.PurgeExpiredActivity, %{activity_id: "some_if"})