Skip to content

Commit

Permalink
Monitor pg scope before making test assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
sorentwo committed May 4, 2024
1 parent 163c4bc commit 1af3747
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/oban/notifiers/pg_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@ defmodule Oban.Notifiers.PGTest do
alias Oban.Notifier
alias Oban.Notifiers.PG

setup do
:pg.start_link(Oban.Notifiers.PG)
:pg.monitor_scope(Oban.Notifiers.PG)

Check warning on line 9 in test/oban/notifiers/pg_test.exs

View workflow job for this annotation

GitHub Actions / ci (1.13, 23.3, 12.13-alpine, lite)

:pg.monitor_scope/1 is undefined or private

:ok
end

describe "namespacing" do
test "namespacing by configured prefix without an override" do

Check failure on line 15 in test/oban/notifiers/pg_test.exs

View workflow job for this annotation

GitHub Actions / ci (1.13, 23.3, 12.13-alpine, lite)

test namespacing namespacing by configured prefix without an override (Oban.Notifiers.PGTest)
name_1 = start_supervised_oban!(notifier: PG, prefix: "pg_test")
name_2 = start_supervised_oban!(notifier: PG, prefix: "pg_test")

assert_joined("pg_test")
assert_joined("pg_test")

:ok = Notifier.listen(name_1, :signal)
:ok = Notifier.notify(name_2, :signal, %{incoming: "message"})

Expand All @@ -19,10 +29,17 @@ defmodule Oban.Notifiers.PGTest do
name_1 = start_supervised_oban!(notifier: {PG, namespace: :pg_test}, prefix: "pg_a")
name_2 = start_supervised_oban!(notifier: {PG, namespace: :pg_test}, prefix: "pg_b")

assert_joined(:pg_test)
assert_joined(:pg_test)

:ok = Notifier.listen(name_1, :signal)
:ok = Notifier.notify(name_2, :signal, %{incoming: "message"})

assert_receive {:notification, :signal, %{"incoming" => "message"}}
end
end

defp assert_joined(group) do
assert_receive {_ref, :join, ^group, _pids}
end
end

0 comments on commit 1af3747

Please sign in to comment.