diff --git a/test/microwaveprop/weather/hrrr_client_test.exs b/test/microwaveprop/weather/hrrr_client_test.exs index 4a7a2261..e1af658d 100644 --- a/test/microwaveprop/weather/hrrr_client_test.exs +++ b/test/microwaveprop/weather/hrrr_client_test.exs @@ -1,5 +1,5 @@ defmodule Microwaveprop.Weather.HrrrClientTest do - use ExUnit.Case, async: true + use ExUnit.Case, async: false alias Microwaveprop.Weather.HrrrClient diff --git a/test/microwaveprop/weather_test.exs b/test/microwaveprop/weather_test.exs index ec2f648d..91e3f8bb 100644 --- a/test/microwaveprop/weather_test.exs +++ b/test/microwaveprop/weather_test.exs @@ -1327,12 +1327,25 @@ defmodule Microwaveprop.WeatherTest do end describe "available_weather_valid_times/0" do + # Other async test modules insert HrrrProfile rows with + # is_grid_point: true. Wipe them so the "empty DB" assertion + # doesn't flake. + setup do + Repo.delete_all(from(h in HrrrProfile, where: h.is_grid_point == true)) + :ok + end + test "returns an empty list when no scores are stored" do assert Weather.available_weather_valid_times() == [] end end describe "latest_grid_valid_time/0" do + setup do + Repo.delete_all(from(h in HrrrProfile, where: h.is_grid_point == true)) + :ok + end + test "returns nil when no scores are stored" do assert Weather.latest_grid_valid_time() == nil end diff --git a/test/microwaveprop_web/controllers/contact_map_controller_test.exs b/test/microwaveprop_web/controllers/contact_map_controller_test.exs index 1567765b..f1d69608 100644 --- a/test/microwaveprop_web/controllers/contact_map_controller_test.exs +++ b/test/microwaveprop_web/controllers/contact_map_controller_test.exs @@ -2,12 +2,21 @@ defmodule MicrowavepropWeb.ContactMapControllerTest do use MicrowavepropWeb.ConnCase, async: false alias Microwaveprop.Cache + alias MicrowavepropWeb.Api.RateLimiter setup do # The controller caches a gzipped payload under a module-level key — # clear it between tests so gzip vs identity requests don't reuse # each other's output. Cache.invalidate({MicrowavepropWeb.ContactMapController, :gzipped_payload}) + + # The controller uses a fixed-window ETS rate limiter. Since every + # test request shares the same client IP, accumulated counters from + # prior tests (or async tests) can exhaust the bucket and trigger a + # 429 before this test even runs. Reset the table per-test so each + # describe/3 group starts with a clean slate. + RateLimiter.reset() + :ok end