Adds ~800 new tests (incl. 27 StreamData properties) across 22 modules that previously had little or no coverage. Highlights: - Pure utility modules (LogSanitizer, PacketFieldWhitelist, PacketSanitizer, DeviceParser, CoordinateUtils, BoundsUtils, ParamUtils, Convert, WeatherUnits) get thorough unit + property coverage including UTF-8 truncation boundaries, antimeridian longitude wrap, Haversine symmetry, and unit-conversion inverses. - JSON view modules (CallsignJSON, ErrorJSON, ChangesetJSON) verified for envelope shape and error templating. - Plugs (HealthCheck, RateLimiter, ApiCSRF) exercised for happy-path and halt paths. - GenServer modules (RegexCache, CleanupScheduler, DeploymentNotifier) tested without touching the supervised singleton where possible. - Drops the orphaned map_live/map_helpers_test.exs whose module name collided with the new live/shared/coordinate_utils_test.exs.
43 lines
1.4 KiB
Elixir
43 lines
1.4 KiB
Elixir
defmodule Aprsme.DeploymentNotifierTest do
|
|
use ExUnit.Case, async: false
|
|
|
|
alias Aprsme.DeploymentNotifier
|
|
|
|
describe "notify_deployment/1" do
|
|
test "broadcasts :new_deployment over Aprsme.PubSub" do
|
|
:ok = Phoenix.PubSub.subscribe(Aprsme.PubSub, "deployment_events")
|
|
now = DateTime.utc_now()
|
|
|
|
assert :ok == DeploymentNotifier.notify_deployment(now)
|
|
|
|
assert_receive {:new_deployment, %{deployed_at: ^now}}, 500
|
|
end
|
|
end
|
|
|
|
describe "handle_info :check_deployment" do
|
|
test "no-op when deployed_at is unchanged" do
|
|
deployed = DateTime.utc_now()
|
|
Application.put_env(:aprsme, :deployed_at, deployed)
|
|
|
|
state = %{deployed_at: deployed}
|
|
assert {:noreply, ^state} = DeploymentNotifier.handle_info(:check_deployment, state)
|
|
end
|
|
|
|
test "broadcasts and updates state when deployed_at has changed" do
|
|
:ok = Phoenix.PubSub.subscribe(Aprsme.PubSub, "deployment_events")
|
|
|
|
new_deploy = DateTime.utc_now()
|
|
old_deploy = DateTime.add(new_deploy, -60, :second)
|
|
|
|
# Simulate an updated deploy timestamp in app env.
|
|
Application.put_env(:aprsme, :deployed_at, new_deploy)
|
|
|
|
state = %{deployed_at: old_deploy}
|
|
|
|
assert {:noreply, %{deployed_at: ^new_deploy}} =
|
|
DeploymentNotifier.handle_info(:check_deployment, state)
|
|
|
|
assert_receive {:new_deployment, %{deployed_at: ^new_deploy}}, 500
|
|
end
|
|
end
|
|
end
|