aprs.me/test/aprsme/postgres_notifier_test.exs
Graham McIntire 16d2e929c0
test: push coverage to 70% with more CoreComponents and PostgresNotifier
- CoreComponents.input/1: expanded coverage to include the select,
  textarea, generic-text, and unchecked-checkbox branches, plus
  error-vs-no-error border styling.
- PostgresNotifier: handle_info forwards pg_notify payload to
  Aprsme.PubSub and ignores unrelated messages.

Coverage 69.56 → 70.11%.
2026-04-23 16:18:04 -05:00

24 lines
862 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"}, 500
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