Skip to content

Commit

Permalink
Handle insert_all with streams for inline engine
Browse files Browse the repository at this point in the history
The inline engine's `insert_all_jobs` callback incorrectly expected
changesets to always be a list rather than a stream.

Closes #1151
  • Loading branch information
sorentwo committed Sep 10, 2024
1 parent cc89021 commit 703b3ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/oban/engines/inline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ defmodule Oban.Engines.Inline do
defp expand(value), do: expand(value, %{})
defp expand(fun, changes) when is_function(fun, 1), do: expand(fun.(changes), changes)
defp expand(%{changesets: changesets}, _), do: expand(changesets, %{})
defp expand(changesets, _) when is_list(changesets), do: changesets
defp expand(changesets, _), do: changesets

# Execution Helpers

Expand Down
11 changes: 11 additions & 0 deletions test/oban/engines/inline_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ defmodule Oban.Engines.InlineTest do
end
end

test "executing multiple jobs inserted from a stream" do
name = start_supervised_oban!(testing: :inline)

stream = Stream.map(1..2, &Worker.new(%{ref: &1, action: "OK"}))

assert [_job_1, _job_2] = Oban.insert_all(name, stream)

assert_receive {:ok, 1}
assert_receive {:ok, 2}
end

test "executing single jobs inserted within a multi" do
name = start_supervised_oban!(testing: :inline)

Expand Down

0 comments on commit 703b3ed

Please sign in to comment.