aprs.me/test/aprsme/signal_handler_test.exs
Graham McIntire c5a82b77c1
refactor: pattern-match over conditionals in Navigation and InsertOptimizer
Swaps `if`/`cond` branches for multi-clause function heads or head-pattern
matching, making the control flow visible in the function signatures:

- Navigation.determine_map_location: resolve_location/4 now dispatches on
  the shape of the geolocation input and whether URL params are explicit.
- Navigation.handle_callsign_tracking: per-case clauses for empty callsign
  and explicit-URL-params short-circuits, plus a final clause that does the
  DB lookup and rescues once.
- Navigation.handle_callsign_search: dispatch_callsign_search/3 separates
  the valid/invalid callsign branches.
- InsertOptimizer.optimize_based_on_performance: pattern-match on
  [_, _, _ | _] to require ≥3 samples without calling length/1.
- InsertOptimizer.calculate_insert_options and throughput helpers split
  into guarded clauses instead of inline `if`.
- maybe_emit_optimization uses same-var pattern matching to skip the
  telemetry hit when nothing changed.

Adds unit tests covering every branch of both modules plus SignalHandler,
LocaleHook, and the InsertOptimizer's :noproc fallback path. Coverage
64.69% → 65.72%.
2026-04-23 13:38:24 -05:00

16 lines
555 B
Elixir

defmodule Aprsme.SignalHandlerTest do
use ExUnit.Case, async: true
alias Aprsme.SignalHandler
describe "handle_info/2" do
test "ignores unrecognized messages without changing state" do
state = %{some: :state}
assert SignalHandler.handle_info(:random, state) == {:noreply, state}
assert SignalHandler.handle_info({:other, "msg"}, state) == {:noreply, state}
end
# We can't safely exercise the :sigterm clause here — it calls
# Aprsme.ShutdownHandler.shutdown() which would actually shut the app down.
end
end