mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-30 17:11:40 +00:00
6da6540036
Done via the following command:
git diff fcd5dd259a
--stat --name-only | xargs sed -i '/Pleroma Authors/c# Copyright © 2017-2020 Pleroma Authors <https:\/\/pleroma.social\/>'
47 lines
973 B
Elixir
47 lines
973 B
Elixir
# Pleroma: A lightweight social networking server
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
defmodule Pleroma.Tests.ObanHelpers do
|
|
@moduledoc """
|
|
Oban test helpers.
|
|
"""
|
|
|
|
alias Pleroma.Repo
|
|
|
|
def wipe_all do
|
|
Repo.delete_all(Oban.Job)
|
|
end
|
|
|
|
def perform_all do
|
|
Oban.Job
|
|
|> Repo.all()
|
|
|> perform()
|
|
end
|
|
|
|
def perform(%Oban.Job{} = job) do
|
|
res = apply(String.to_existing_atom("Elixir." <> job.worker), :perform, [job.args, job])
|
|
Repo.delete(job)
|
|
res
|
|
end
|
|
|
|
def perform(jobs) when is_list(jobs) do
|
|
for job <- jobs, do: perform(job)
|
|
end
|
|
|
|
def member?(%{} = job_args, jobs) when is_list(jobs) do
|
|
Enum.any?(jobs, fn job ->
|
|
member?(job_args, job.args)
|
|
end)
|
|
end
|
|
|
|
def member?(%{} = test_attrs, %{} = attrs) do
|
|
Enum.all?(
|
|
test_attrs,
|
|
fn {k, _v} -> member?(test_attrs[k], attrs[k]) end
|
|
)
|
|
end
|
|
|
|
def member?(x, y), do: x == y
|
|
end
|