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