Skip to content

Commit 3ebfe78

Browse files
committed
fix: restore rate_limit config after rate_limiter tests
Added on_exit callback to rate_limiter_test.exs to restore the original rate_limit configuration after each test. This prevents test configuration from bleeding into other tests, which was causing 15 test failures due to the rate limit being set to 2 instead of the test_helper value of 10,000. All 127 tests now pass.
1 parent f5dcb24 commit 3ebfe78

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/phoenix/session_process/rate_limiter_test.exs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ defmodule Phoenix.SessionProcess.RateLimiterTest do
66
setup do
77
# Reset rate limiter before each test
88
RateLimiter.reset()
9+
10+
# Save original rate limit configuration
11+
original_rate_limit = Application.get_env(:phoenix_session_process, :rate_limit)
12+
13+
# Restore rate limit after each test
14+
on_exit(fn ->
15+
if original_rate_limit do
16+
Application.put_env(:phoenix_session_process, :rate_limit, original_rate_limit)
17+
else
18+
Application.delete_env(:phoenix_session_process, :rate_limit)
19+
end
20+
RateLimiter.reset()
21+
end)
22+
923
:ok
1024
end
1125

0 commit comments

Comments
 (0)