Skip to content

Commit

Permalink
Only check pid ancestors for inline override
Browse files Browse the repository at this point in the history
Ancestors may be registered names such as atoms or global tuples, and
not necessarily a pid. Now the process dictionary is only checked for
pid ancestors.
  • Loading branch information
sorentwo committed Apr 22, 2024
1 parent 63b0751 commit d5b2e89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/oban/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,14 @@ defmodule Oban.Config do
end
end

defp inline_testing?(pid, default) do
defp inline_testing?(pid, default) when is_pid(pid) do
{:dictionary, dictionary} = Process.info(pid, :dictionary)

Keyword.get(dictionary, :oban_testing, default) == :inline
end

defp inline_testing?(_pid, _default), do: false

@doc false
@spec node_name(%{optional(binary()) => binary()}) :: binary()
def node_name(env \\ System.get_env()) do
Expand Down
2 changes: 2 additions & 0 deletions test/oban/testing_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@ defmodule Oban.TestingTest do

Testing.with_testing_mode(:inline, fn ->
fun = fn ->
Process.put(:"$ancestors", [Some.Endpoint | Process.get(:"$ancestors")])

Oban.insert!(name, Worker.new(%{ref: 1, action: "OK"}))

assert_received {:ok, 1}
Expand Down

0 comments on commit d5b2e89

Please sign in to comment.