X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Factivity_expiration_test.exs;h=d75c06cc7e61aaad1a2dc22f32ec24334c67c691;hb=cc196e2cd57966889021342405ebc8fd0763e83a;hp=4948fae16b79f317569771ff1ecde5e5f520de4e;hpb=83aeb6090072986d39dc52de05f5a23164f8ce04;p=akkoma
diff --git a/test/activity_expiration_test.exs b/test/activity_expiration_test.exs
index 4948fae16..d75c06cc7 100644
--- a/test/activity_expiration_test.exs
+++ b/test/activity_expiration_test.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ActivityExpirationTest do
@@ -7,6 +7,8 @@ defmodule Pleroma.ActivityExpirationTest do
alias Pleroma.ActivityExpiration
import Pleroma.Factory
+ setup do: clear_config([ActivityExpiration, :enabled])
+
test "finds activities due to be deleted only" do
activity = insert(:note_activity)
expiration_due = insert(:expiration_in_the_past, %{activity_id: activity.id})
@@ -24,4 +26,27 @@ defmodule Pleroma.ActivityExpirationTest do
now = NaiveDateTime.utc_now()
assert {:error, _} = ActivityExpiration.create(activity, now)
end
+
+ test "deletes an expiration activity" do
+ Pleroma.Config.put([ActivityExpiration, :enabled], true)
+ activity = insert(:note_activity)
+
+ naive_datetime =
+ NaiveDateTime.add(
+ NaiveDateTime.utc_now(),
+ -:timer.minutes(2),
+ :millisecond
+ )
+
+ expiration =
+ insert(
+ :expiration_in_the_past,
+ %{activity_id: activity.id, scheduled_at: naive_datetime}
+ )
+
+ Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker.perform(%Oban.Job{})
+
+ refute Pleroma.Repo.get(Pleroma.Activity, activity.id)
+ refute Pleroma.Repo.get(Pleroma.ActivityExpiration, expiration.id)
+ end
end