1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule MockActivityPub do
6 def publish_one({ret, waiter}) do
7 send(waiter, :complete)
12 defmodule Pleroma.Web.Federator.RetryQueueTest do
14 alias Pleroma.Web.Federator.RetryQueue
17 @hopeless_retry_count 10
20 RetryQueue.reset_stats()
23 test "RetryQueue responds to stats request" do
24 assert %{delivered: 0, dropped: 0} == RetryQueue.get_stats()
27 test "failed posts are retried" do
28 {:retry, _timeout} = RetryQueue.get_retry_params(@small_retry_count)
37 RetryQueue.enqueue({:ok, wait_task.pid}, MockActivityPub, @small_retry_count)
39 assert %{delivered: 1, dropped: 0} == RetryQueue.get_stats()
42 test "posts that have been tried too many times are dropped" do
43 {:drop, _timeout} = RetryQueue.get_retry_params(@hopeless_retry_count)
45 RetryQueue.enqueue({:ok, nil}, MockActivityPub, @hopeless_retry_count)
46 assert %{delivered: 0, dropped: 1} == RetryQueue.get_stats()