test: dispatch various APRS packet formats in Is tests

This commit is contained in:
Graham McIntire 2026-04-23 17:23:59 -05:00
parent bf117fc6c8
commit 56bc152b49
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -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})