From c6db35afe7749846b3272d5476b6a5d65938c439 Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Tue, 27 Feb 2024 09:42:27 -0500 Subject: [PATCH] chore: ensure repo is present in oban pro config --- .credo.exs | 1 + lib/ash_oban.ex | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.credo.exs b/.credo.exs index 3d2c080..6e7228a 100644 --- a/.credo.exs +++ b/.credo.exs @@ -126,6 +126,7 @@ {Credo.Check.Refactor.Nesting, [max_nesting: 6]}, {Credo.Check.Refactor.UnlessWithElse, []}, {Credo.Check.Refactor.WithClauses, []}, + {Credo.Check.Refactor.Apply, false}, # ## Warnings diff --git a/lib/ash_oban.ex b/lib/ash_oban.ex index a8b6550..4043759 100644 --- a/lib/ash_oban.ex +++ b/lib/ash_oban.ex @@ -673,6 +673,7 @@ defmodule AshOban do - `scheduled_actions?` - Defaults to false, unless a scheduled action name was explicitly provided. Schedules all applicable scheduled actions. - `triggers?` - Defaults to true, schedules all applicable scheduled actions. - `actor` - The actor to schedule and run the triggers with + - `oban` - The oban module to use. Defaults to `Oban` If the input is: * a list - each item is passed into `schedule_and_run_triggers/1`, and the results are merged together. @@ -688,6 +689,7 @@ defmodule AshOban do |> Keyword.put_new(:scheduled_actions?, false) |> Keyword.put_new(:triggers?, true) |> Keyword.put_new(:drain_queues?, false) + |> Keyword.put_new(:oban, Oban) do_schedule_and_run_triggers(resources_or_apis_or_otp_apps, opts) end @@ -798,7 +800,11 @@ defmodule AshOban do if @pro do defp drain_queue(opts) do - Oban.Pro.Testing.drain_jobs(opts) + conf = Oban.config(opts[:oban]) + + opts = Keyword.put_new(opts, :repo, conf.repo) + + apply(Oban.Pro.Testing, :drain_jobs, [opts]) end else if Application.compile_env(:ash_oban, :test) || Mix.env() == :test do