test: reset rate-limiter ETS between api controller tests to prevent 429 flakes

This commit is contained in:
Graham McIntire 2026-04-23 17:19:00 -05:00
parent dac0198825
commit 4a00868c2a
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59
2 changed files with 22 additions and 0 deletions

View file

@ -5,6 +5,17 @@ defmodule AprsmeWeb.Api.V1.CallsignControllerTest do
import Aprsme.PacketsFixtures
setup do
# Reset the Hammer rate-limiter ETS table so we don't trigger 429s from
# accumulated hits across the full test suite.
case :ets.info(Aprsme.RateLimiter) do
:undefined -> :ok
_ -> :ets.delete_all_objects(Aprsme.RateLimiter)
end
:ok
end
describe "GET /api/v1/callsign/:callsign" do
test "returns 400 for an invalid callsign format", %{conn: conn} do
conn = get(conn, ~p"/api/v1/callsign/invalid@callsign")

View file

@ -3,6 +3,17 @@ defmodule AprsmeWeb.Api.V1.WeatherControllerTest do
import Aprsme.PacketsFixtures
setup do
# Reset the Hammer rate-limiter ETS table so we don't trigger 429s from
# accumulated hits across the full test suite.
case :ets.info(Aprsme.RateLimiter) do
:undefined -> :ok
_ -> :ets.delete_all_objects(Aprsme.RateLimiter)
end
:ok
end
describe "GET /api/v1/weather/nearby" do
setup do
# Create a weather station packet