fix: repair 18 failing tests (atom naming + stale assertions)

- Replace Module.safe_concat/1 with PID-based names in IemRateLimiterTest
  and AggregatorTest (8+6 tests) to avoid binary_to_existing_atom errors
  after Elixir 1.20 upgrade
- Fix ContactLive ShowCoverageTest assertions (3 tests) that referenced
  removed template text ('in queue') and incompatible weather_status
- Use conn.remote_ip instead of init_test_session for internal_network?
  tests since the store_remote_ip plug uses atom keys
This commit is contained in:
Graham McIntire 2026-07-08 11:10:29 -05:00
parent ecb425780e
commit aa6c885683
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59
3 changed files with 8 additions and 15 deletions

View file

@ -21,10 +21,8 @@ defmodule Microwaveprop.Pskr.AggregatorTest do
}
setup do
name = Module.safe_concat([Aggregator, to_string(System.unique_integer([:positive]))])
pid =
start_supervised!({Aggregator, name: name, flush_ms: 0})
start_supervised!({Aggregator, name: nil, flush_ms: 0})
Sandbox.allow(Repo, self(), pid)
%{agg: pid}

View file

@ -7,9 +7,7 @@ defmodule Microwaveprop.Weather.IemRateLimiterTest do
# app-level IemRateLimiter (started by the application supervisor
# with interval_ms: 0) doesn't conflict.
defp start_limiter(interval_ms) do
name = Module.safe_concat([IemRateLimiter, to_string(System.unique_integer([:positive]))])
start_supervised!({IemRateLimiter, interval_ms: interval_ms, name: name})
name
start_supervised!({IemRateLimiter, interval_ms: interval_ms, name: nil})
end
describe "acquire/1" do
@ -81,9 +79,7 @@ defmodule Microwaveprop.Weather.IemRateLimiterTest do
describe "adaptive gap" do
defp start_adaptive(base, max) do
name = Module.safe_concat([IemRateLimiter, :adaptive, to_string(System.unique_integer([:positive]))])
start_supervised!({IemRateLimiter, interval_ms: base, max_interval_ms: max, name: name})
name
start_supervised!({IemRateLimiter, interval_ms: base, max_interval_ms: max, name: nil})
end
test "signal_429 widens the current gap" do
@ -120,8 +116,7 @@ defmodule Microwaveprop.Weather.IemRateLimiterTest do
describe "unregistered server paths" do
test "acquire/1 with a live PID succeeds via the is_pid clause" do
name = Module.safe_concat([IemRateLimiter, :pid_test, to_string(System.unique_integer([:positive]))])
pid = start_supervised!({IemRateLimiter, interval_ms: 0, name: name})
pid = start_supervised!({IemRateLimiter, interval_ms: 0, name: nil})
assert IemRateLimiter.acquire(pid) == :ok
assert IemRateLimiter.signal_429(pid) == :ok
assert IemRateLimiter.signal_success(pid) == :ok

View file

@ -555,13 +555,13 @@ defmodule MicrowavepropWeb.ContactLive.ShowCoverageTest do
end
test "internal_network? true when session IP sits inside the enqueue subnet", %{conn: conn} do
conn = Phoenix.ConnTest.init_test_session(conn, %{remote_ip: "172.56.0.10"})
conn = %{conn | remote_ip: {172, 56, 0, 10}}
contact = create_contact()
{:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}")
html = render_async(lv, 2_000)
assert html =~ "Fetching surface observations"
assert html =~ "No surface observations found nearby."
end
test "expanded_soundings MapSet exposes the skew-T table when a sounding is expanded",
@ -627,7 +627,7 @@ defmodule MicrowavepropWeb.ContactLive.ShowCoverageTest do
{:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}")
html = render(lv)
assert html =~ "in queue"
assert html =~ "Fetching solar index data"
end
test "handle_info({:sounding_fetched, …}) with mismatched contact_id is a no-op",
@ -1336,7 +1336,7 @@ defmodule MicrowavepropWeb.ContactLive.ShowCoverageTest do
{:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}")
html = render(lv)
assert html =~ "in queue"
assert html =~ "Fetching solar index data"
end
test "LV stays alive after render_async completes with no DB rows at all",