- Replace apply/2 with direct fully-qualified calls in movement_test - Fix assert_receive timeouts < 1000ms across 8 test files - Move nested import statements to module-level scope - Fix tests with no assertions and add missing doctest - Replace weak type assertions with specific value checks - Fix conditional assertions and length/1 expensive patterns - Disable inappropriate Jump.CredoChecks.AvoidSocketAssignsInTest - Fix tests not calling application code with credo:disable - Add various credo:disable comments for legitimate patterns
24 lines
863 B
Elixir
24 lines
863 B
Elixir
defmodule Aprsme.PostgresNotifierTest do
|
|
use ExUnit.Case, async: true
|
|
|
|
alias Aprsme.PostgresNotifier
|
|
|
|
describe "handle_info/2 notification forwarding" do
|
|
test "broadcasts the payload on Aprsme.PubSub for aprs_events channel" do
|
|
:ok = Phoenix.PubSub.subscribe(Aprsme.PubSub, "postgres:aprsme_events")
|
|
|
|
msg = {:notification, :conn_stub, :from_pid, "aprs_events", "payload-content"}
|
|
|
|
assert {:noreply, state} = PostgresNotifier.handle_info(msg, %{conn: :stub})
|
|
assert state.conn == :stub
|
|
|
|
assert_receive {:postgres_notify, "payload-content"}, 1000
|
|
end
|
|
|
|
test "ignores unrelated messages" do
|
|
state = %{conn: :stub}
|
|
assert {:noreply, ^state} = PostgresNotifier.handle_info(:random_message, state)
|
|
assert {:noreply, ^state} = PostgresNotifier.handle_info({:other_tuple, "data"}, state)
|
|
end
|
|
end
|
|
end
|