Fix Oban related tests
This commit is contained in:
parent
0847d9ebaf
commit
f63e44b8bc
@ -31,8 +31,7 @@ defmodule Pleroma.ScheduledActivityTest 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
|
||||||
|
@ -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 @@ defmodule Pleroma.Web.MastodonAPI.ScheduledActivityControllerTest 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 @@ defmodule Pleroma.Web.MastodonAPI.ScheduledActivityControllerTest 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 @@ defmodule Pleroma.Web.MastodonAPI.ScheduledActivityControllerTest 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
|
||||||
|
Loading…
Reference in New Issue
Block a user