Skip to content

Commit

Permalink
Adapt tests to OTP26 (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
danmarcab authored Aug 27, 2023
1 parent f9f13e2 commit 3227bf0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
3 changes: 2 additions & 1 deletion test/allocator_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ defmodule BroadwayKafka.AllocatorTest do
entry <- entries,
do: ^partition = fetch!(name, entry)

map
# ensure the value list is sorted, to be able to reliably assert
Map.new(map, fn {k, v} -> {k, Enum.sort(v)} end)
end
end
28 changes: 13 additions & 15 deletions test/producer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,12 @@ defmodule BroadwayKafka.ProducerTest do
test "do not allow users to set :partition_by for processors" do
Process.flag(:trap_exit, true)

Broadway.start_link(Forwarder,
name: new_unique_name(),
producer: [module: {BroadwayKafka.Producer, []}],
processors: [default: [partition_by: fn msg -> msg.data end]]
)

assert_receive {:EXIT, _, {%ArgumentError{message: message}, _}}
{:error, {%ArgumentError{message: message}, _}} =
Broadway.start_link(Forwarder,
name: new_unique_name(),
producer: [module: {BroadwayKafka.Producer, []}],
processors: [default: [partition_by: fn msg -> msg.data end]]
)

assert message ==
"cannot set option :partition_by for processors :default. " <>
Expand All @@ -189,14 +188,13 @@ defmodule BroadwayKafka.ProducerTest do
test "do not allow users to set :partition_by for batchers" do
Process.flag(:trap_exit, true)

Broadway.start_link(Forwarder,
name: new_unique_name(),
producer: [module: {BroadwayKafka.Producer, []}],
processors: [default: []],
batchers: [default: [partition_by: fn msg -> msg.data end]]
)

assert_receive {:EXIT, _, {%ArgumentError{message: message}, _}}
{:error, {%ArgumentError{message: message}, _}} =
Broadway.start_link(Forwarder,
name: new_unique_name(),
producer: [module: {BroadwayKafka.Producer, []}],
processors: [default: []],
batchers: [default: [partition_by: fn msg -> msg.data end]]
)

assert message ==
"cannot set option :partition_by for batchers :default. " <>
Expand Down

0 comments on commit 3227bf0

Please sign in to comment.