Fix Oban related tests

This commit is contained in:
Mark Felder 2024-05-27 13:46:15 -04:00
parent 0847d9ebaf
commit f63e44b8bc
2 changed files with 13 additions and 7 deletions

View File

@ -31,8 +31,7 @@ test "scheduled activities with jobs when ScheduledActivity enabled" do
{:ok, sa1} = ScheduledActivity.create(user, attrs) {:ok, sa1} = ScheduledActivity.create(user, attrs)
{:ok, sa2} = ScheduledActivity.create(user, attrs) {:ok, sa2} = ScheduledActivity.create(user, attrs)
jobs = jobs = Repo.all(from(j in Oban.Job, where: j.queue == "federator_outgoing", select: j.args))
Repo.all(from(j in Oban.Job, where: j.queue == "scheduled_activities", select: j.args))
assert jobs == [%{"activity_id" => sa1.id}, %{"activity_id" => sa2.id}] assert jobs == [%{"activity_id" => sa1.id}, %{"activity_id" => sa2.id}]
end end

View File

@ -3,6 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only # SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.ScheduledActivityControllerTest do defmodule Pleroma.Web.MastodonAPI.ScheduledActivityControllerTest do
use Oban.Testing, repo: Pleroma.Repo
use Pleroma.Web.ConnCase, async: true use Pleroma.Web.ConnCase, async: true
alias Pleroma.Repo alias Pleroma.Repo
@ -78,7 +79,7 @@ test "updates a scheduled activity" do
} }
) )
job = Repo.one(from(j in Oban.Job, where: j.queue == "scheduled_activities")) job = Repo.one(from(j in Oban.Job, where: j.queue == "federator_outgoing"))
assert job.args == %{"activity_id" => scheduled_activity.id} assert job.args == %{"activity_id" => scheduled_activity.id}
assert DateTime.truncate(job.scheduled_at, :second) == to_datetime(scheduled_at) assert DateTime.truncate(job.scheduled_at, :second) == to_datetime(scheduled_at)
@ -124,9 +125,11 @@ test "deletes a scheduled activity" do
} }
) )
job = Repo.one(from(j in Oban.Job, where: j.queue == "scheduled_activities")) assert_enqueued(
worker: Pleroma.Workers.ScheduledActivityWorker,
assert job.args == %{"activity_id" => scheduled_activity.id} args: %{"activity_id" => scheduled_activity.id},
queue: :federator_outgoing
)
res_conn = res_conn =
conn conn
@ -135,7 +138,11 @@ test "deletes a scheduled activity" do
assert %{} = json_response_and_validate_schema(res_conn, 200) assert %{} = json_response_and_validate_schema(res_conn, 200)
refute Repo.get(ScheduledActivity, scheduled_activity.id) refute Repo.get(ScheduledActivity, scheduled_activity.id)
refute Repo.get(Oban.Job, job.id)
refute_enqueued(
worker: Pleroma.Workers.ScheduledActivityWorker,
args: %{"activity_id" => scheduled_activity.id}
)
res_conn = res_conn =
conn conn