From 20b38cbf4004f164e7f584ebba02ecb99b58311c Mon Sep 17 00:00:00 2001 From: Parker Selbert Date: Mon, 27 Nov 2023 09:59:24 -0600 Subject: [PATCH] Disable the prefix by default in testing helpers A prefix is only necessary when it's not the standard "public" prefix, which is rarely the case in testing helpers. Closes #992 --- lib/oban.ex | 2 +- lib/oban/testing.ex | 12 ++++++------ test/oban/testing_test.exs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/oban.ex b/lib/oban.ex index 9543bec4..9589e024 100644 --- a/lib/oban.ex +++ b/lib/oban.ex @@ -49,7 +49,7 @@ defmodule Oban do | {:notifier, module() | {module(), Keyword.t()}} | {:peer, false | module() | {module(), Keyword.t()}} | {:plugins, false | [module() | {module() | Keyword.t()}]} - | {:prefix, String.t()} + | {:prefix, false | String.t()} | {:queues, false | [{queue_name(), pos_integer() | Keyword.t()}]} | {:repo, module()} | {:shutdown_grace_period, timeout()} diff --git a/lib/oban/testing.ex b/lib/oban/testing.ex index fb0d5104..96ef935d 100644 --- a/lib/oban/testing.ex +++ b/lib/oban/testing.ex @@ -103,11 +103,7 @@ defmodule Oban.Testing do alias Oban.{Config, Job, Queue.Executor, Repo, Worker} - @type perform_opts :: - Job.option() - | {:log, Logger.level()} - | {:prefix, binary()} - | {:repo, module()} + @type perform_opts :: Job.option() | Oban.option() @conf_keys [] |> Config.new() @@ -120,7 +116,11 @@ defmodule Oban.Testing do @doc false defmacro __using__(repo_opts) do - _repo = Keyword.fetch!(repo_opts, :repo) + repo_opts = Keyword.put_new(repo_opts, :prefix, false) + + unless Keyword.has_key?(repo_opts, :repo) do + raise ArgumentError, "testing requires a :repo option to be set" + end quote do alias Oban.Testing diff --git a/test/oban/testing_test.exs b/test/oban/testing_test.exs index a3e8aa95..d4b0521c 100644 --- a/test/oban/testing_test.exs +++ b/test/oban/testing_test.exs @@ -1,7 +1,7 @@ defmodule Oban.TestingTest do use Oban.Case, async: true - use Oban.Testing, repo: Oban.Test.Repo, prefix: "public", log: false + use Oban.Testing, repo: Oban.Test.Repo, log: false alias Oban.{TelemetryHandler, Testing}