diff --git a/middleware/rate_limiter_test.go b/middleware/rate_limiter_test.go index ff363368d..eee6e7f97 100644 --- a/middleware/rate_limiter_test.go +++ b/middleware/rate_limiter_test.go @@ -24,13 +24,13 @@ func TestRateLimiter(t *testing.T) { id string code int }{ - {"127.0.0.1", 200}, - {"127.0.0.1", 200}, {"127.0.0.1", 200}, {"127.0.0.1", 200}, {"127.0.0.1", 200}, {"127.0.0.1", 429}, - {"127.0.0.1", 200}, + {"127.0.0.1", 429}, + {"127.0.0.1", 429}, + {"127.0.0.1", 429}, } for _, tc := range testCases { @@ -47,7 +47,6 @@ func TestRateLimiter(t *testing.T) { _ = mw(handler)(c) assert.Equal(t, tc.code, rec.Code) - time.Sleep(500 * time.Millisecond) } } @@ -66,13 +65,13 @@ func TestRateLimiterWithConfig(t *testing.T) { id string code int }{ - {"127.0.0.1", 200}, - {"127.0.0.1", 200}, {"127.0.0.1", 200}, {"127.0.0.1", 200}, {"127.0.0.1", 200}, {"127.0.0.1", 429}, - {"127.0.0.1", 200}, + {"127.0.0.1", 429}, + {"127.0.0.1", 429}, + {"127.0.0.1", 429}, } for _, tc := range testCases { @@ -92,7 +91,6 @@ func TestRateLimiterWithConfig(t *testing.T) { _ = mw(handler)(c) assert.Equal(t, tc.code, rec.Code) - time.Sleep(500 * time.Millisecond) } } @@ -105,19 +103,18 @@ func TestInMemoryStore_ShouldAllow(t *testing.T) { id string allowed bool }{ - {"127.0.0.1", true}, - {"127.0.0.1", true}, {"127.0.0.1", true}, {"127.0.0.1", true}, {"127.0.0.1", true}, {"127.0.0.1", false}, - {"127.0.0.1", true}, + {"127.0.0.1", false}, + {"127.0.0.1", false}, + {"127.0.0.1", false}, } for _, tc := range testCases { allowed := inMemoryStore.ShouldAllow(tc.id) assert.Equal(t, tc.allowed, allowed) - time.Sleep(500 * time.Millisecond) } }