diff --git a/test/aprsme/is_test.exs b/test/aprsme/is_test.exs index 2297f4b..70fb488 100644 --- a/test/aprsme/is_test.exs +++ b/test/aprsme/is_test.exs @@ -360,6 +360,56 @@ defmodule Aprsme.IsTest do end end + describe "dispatch/1 with various APRS formats" do + setup do + ensure_ets_table() + Logger.configure(level: :error) + on_exit(fn -> Logger.configure(level: :error) end) + :ok + end + + test "dispatches a position-with-timestamp packet" do + raw = "N0CALL>APRS,WIDE1-1:/092345z3300.00N/09600.00W>Test" + capture_log(fn -> Aprsme.Is.dispatch(raw) end) + end + + test "dispatches a telemetry packet" do + raw = "N0CALL>APRS,WIDE1-1:T#001,000,000,000,000,000,00000000" + capture_log(fn -> Aprsme.Is.dispatch(raw) end) + end + + test "dispatches a status packet" do + raw = "N0CALL>APRS,WIDE1-1:>Status update text" + capture_log(fn -> Aprsme.Is.dispatch(raw) end) + end + + test "dispatches a message packet" do + raw = "N0CALL>APRS,WIDE1-1::KE5ABC :Hello{001" + capture_log(fn -> Aprsme.Is.dispatch(raw) end) + end + + test "dispatches an object packet" do + raw = "N0CALL>APRS,WIDE1-1:;MyObj *111111z3300.00N/09600.00W-" + capture_log(fn -> Aprsme.Is.dispatch(raw) end) + end + + test "dispatches an item packet" do + raw = "N0CALL>APRS,WIDE1-1:)MyItem!3300.00N/09600.00W-" + capture_log(fn -> Aprsme.Is.dispatch(raw) end) + end + + test "dispatches an empty string (no-op)" do + assert Aprsme.Is.dispatch("") == nil + end + + test "dispatches a comment (starts with #)" do + capture_log(fn -> + # dispatch returns :ok for server comments without crashing. + assert Aprsme.Is.dispatch("# server comment") in [nil, :ok] + end) + end + end + describe "terminate/2" do test "terminates cleanly with nil socket" do state = build_state(%{socket: nil})