Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions internal/middleware/ratelimiter/rate_limiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,16 @@ func TestMiddleware_RateLimitsRequests(t *testing.T) {
rateLimitedCount := 0

// Make 5 rapid requests
for i := 0; i < 5; i++ {
for range 5 {
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/test", nil)
req.RemoteAddr = "192.168.1.1:1234" // Same IP for all requests
r.ServeHTTP(w, req)

if w.Code == http.StatusOK {
switch w.Code {
case http.StatusOK:
successCount++
} else if w.Code == http.StatusTooManyRequests {
case http.StatusTooManyRequests:
rateLimitedCount++
}
}
Expand Down Expand Up @@ -125,7 +126,7 @@ func TestMiddleware_DifferentIPs(t *testing.T) {

for _, ip := range ips {
// Each IP should get 2 successful requests (burst)
for i := 0; i < 2; i++ {
for range 2 {
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/test", nil)
req.RemoteAddr = ip
Expand Down