From aa6c885683bce68a11ae91fcd4a344514000fb38 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Wed, 8 Jul 2026 11:10:29 -0500 Subject: [PATCH] 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 --- test/microwaveprop/pskr/aggregator_test.exs | 4 +--- test/microwaveprop/weather/iem_rate_limiter_test.exs | 11 +++-------- .../live/contact_live/show_coverage_test.exs | 8 ++++---- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/test/microwaveprop/pskr/aggregator_test.exs b/test/microwaveprop/pskr/aggregator_test.exs index c79658a3..b1b20028 100644 --- a/test/microwaveprop/pskr/aggregator_test.exs +++ b/test/microwaveprop/pskr/aggregator_test.exs @@ -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} diff --git a/test/microwaveprop/weather/iem_rate_limiter_test.exs b/test/microwaveprop/weather/iem_rate_limiter_test.exs index f3aab2d2..77dec925 100644 --- a/test/microwaveprop/weather/iem_rate_limiter_test.exs +++ b/test/microwaveprop/weather/iem_rate_limiter_test.exs @@ -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 diff --git a/test/microwaveprop_web/live/contact_live/show_coverage_test.exs b/test/microwaveprop_web/live/contact_live/show_coverage_test.exs index 3fcfa58a..9502c2ec 100644 --- a/test/microwaveprop_web/live/contact_live/show_coverage_test.exs +++ b/test/microwaveprop_web/live/contact_live/show_coverage_test.exs @@ -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",