Skip to content

Commit

Permalink
add was_leader? to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
notslang committed Sep 16, 2024
1 parent 41b0986 commit 3c1b94c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions test/oban/peers/global_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ defmodule Oban.Peers.GlobalTest do

start_supervised_oban!(peer: Global, node: "worker.1")

assert_receive {:event, [:election, :start], _measure, %{leader: _, peer: Oban.Peers.Global}}
assert_receive {:event, [:election, :stop], _measure, %{leader: _, peer: Oban.Peers.Global}}
assert_receive {:event, [:election, :start], _measure,
%{leader: _, peer: Oban.Peers.Global, was_leader?: nil}}

assert_receive {:event, [:election, :stop], _measure,
%{leader: _, peer: Oban.Peers.Global, was_leader?: false}}
end
end
7 changes: 5 additions & 2 deletions test/oban/peers/postgres_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ defmodule Oban.Peers.PostgresTest do
|> Enum.map(&start_supervised!({Peer, conf: conf, name: &1}))
|> Enum.filter(&Postgres.leader?/1)

assert_received {:event, [:election, :start], _measure, %{leader: _, peer: Postgres}}
assert_received {:event, [:election, :stop], _measure, %{leader: _, peer: Postgres}}
assert_received {:event, [:election, :start], _measure,
%{leader: _, peer: Postgres, was_leader?: nil}}

assert_received {:event, [:election, :stop], _measure,
%{leader: _, peer: Postgres, was_leader?: false}}
end

test "gracefully handling a missing oban_peers table" do
Expand Down

0 comments on commit 3c1b94c

Please sign in to comment.