test: reset rate-limiter ETS between api controller tests to prevent 429 flakes
This commit is contained in:
parent
dac0198825
commit
4a00868c2a
2 changed files with 22 additions and 0 deletions
|
|
@ -5,6 +5,17 @@ defmodule AprsmeWeb.Api.V1.CallsignControllerTest do
|
||||||
|
|
||||||
import Aprsme.PacketsFixtures
|
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
|
describe "GET /api/v1/callsign/:callsign" do
|
||||||
test "returns 400 for an invalid callsign format", %{conn: conn} do
|
test "returns 400 for an invalid callsign format", %{conn: conn} do
|
||||||
conn = get(conn, ~p"/api/v1/callsign/invalid@callsign")
|
conn = get(conn, ~p"/api/v1/callsign/invalid@callsign")
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,17 @@ defmodule AprsmeWeb.Api.V1.WeatherControllerTest do
|
||||||
|
|
||||||
import Aprsme.PacketsFixtures
|
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
|
describe "GET /api/v1/weather/nearby" do
|
||||||
setup do
|
setup do
|
||||||
# Create a weather station packet
|
# Create a weather station packet
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue