You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Oban.Testing.with_testing_mode(:inline, fn ->
list
|> Task.async_stream(
fn el -> do_thing_and_enqueue_job(el) end,
max_concurrency: 5
)
|> Enum.map(fn {:ok, res} -> res end)
end)
and a config that sets the default testing to :manual
then the test fails with a timeout because the job never runs (it runs in :manual mode, ignoring the with_testing_mode)
Expected Behavior
Enqueuing a job within Task.async_stream would honor the testing mode specified in with_testing_mode. This issue would also be relevant with browser testing where the test process is different from the process that enqueues the job.
Workaround
Oban.Testing.with_testing_mode(:inline, fn ->
oban_testing_state = Process.get(:oban_testing)
list
|> Task.async_stream(
fn el ->
Process.put(:oban_testing, oban_testing_state)
do_thing_and_enqueue_job(el)
end,
max_concurrency: 5
)
|> Enum.map(fn {:ok, res} -> res end)
end)
Similarly it also works correctly when the work is done in the same process:
Oban.Testing.with_testing_mode(:inline, fn ->
list
|> Enum.map(fn el -> do_thing_and_enqueue_job(el) end)
end)
The text was updated successfully, but these errors were encountered:
Environment
elixir --version
) Elixir 1.16.2 (compiled with Erlang/OTP 26)Current Behavior
Given a test with the code:
and a config that sets the default testing to :manual
then the test fails with a timeout because the job never runs (it runs in :manual mode, ignoring the with_testing_mode)
Expected Behavior
Enqueuing a job within Task.async_stream would honor the testing mode specified in with_testing_mode. This issue would also be relevant with browser testing where the test process is different from the process that enqueues the job.
Workaround
Similarly it also works correctly when the work is done in the same process:
The text was updated successfully, but these errors were encountered: