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.ScheduledActivityWorkerTest do
8 alias Pleroma.ScheduledActivity
9 alias Pleroma.Workers.ScheduledActivityWorker
11 import Pleroma.Factory
12 import ExUnit.CaptureLog
14 setup do: clear_config([ScheduledActivity, :enabled], true)
16 test "creates a status from the scheduled activity" do
21 NaiveDateTime.utc_now(),
29 scheduled_at: naive_datetime,
31 params: %{status: "hi"}
34 {:ok, %{id: activity_id}} =
35 ScheduledActivityWorker.perform(%Oban.Job{args: %{"activity_id" => scheduled_activity.id}})
37 refute Repo.get(ScheduledActivity, scheduled_activity.id)
41 |> Repo.get(activity_id)
42 |> Pleroma.Object.normalize()
44 assert object.data["content"] == "hi"
47 test "error message for non-existent scheduled activity" do
48 assert capture_log([level: :error], fn ->
49 ScheduledActivityWorker.perform(%Oban.Job{args: %{"activity_id" => 42}})
50 end) =~ "Couldn't find scheduled activity: 42"