I’m working on an app which sets Oban’s testing: :inline
in config/test.exs
. In hindsight, :manual
would be better, but switching will be painful.
I have a specific test where several processes are involved. With :inline
, the Oban job is the same process as the one that inserts it, which causes an issue. I’m trying to use :manual
mode to prevent that. Oban.Testing.with_mode(:manual, fn -> ... end)
doesn’t do it, but that makes sense given the multiple processes involved. But temporarily altering the global application env var like this also doesn’t work:
# aysnc: false because we are monkeying with global env settings
use MyAppWeb.ChannelCase, async: false
setup do
prior_testing_mode =
Application.get_env(:myapp, Oban)
|> Keyword.fetch!(:testing)
Application.put_env(:myapp, Oban, testing: :manual)
on_exit(fn ->
Application.put_env(:myapp, Oban, testing: prior_testing_mode)
end)
end
If I change it in config/test.exs
, it does fix this test, it just breaks a lot of others.
So it seems there is no way to change this setting application-wide except at compile time. Is that correct?