TestNew | Basic middleware creation | Middleware processes request successfully |
TestLimiter_RateLimited | Rate limiting enforcement | First request succeeds, immediate second request is blocked with 429 |
TestLimiter_CurrentRate | Current rate retrieval | Returns the configured initial rate |
TestLimiter_Stats | Statistics retrieval | Returns current rate, min/max bounds, and request/error counts |
TestSimple | Simple preset configuration | Middleware works with default simple settings |
TestHighThroughput | High throughput preset | Handles 100 concurrent requests with some successes |
TestConservative | Conservative preset | Middleware works with conservative settings |
TestRetryAfterHeader | Retry-After header on rate limit | Returns βRetry-After: 1β header when rate limited |
TestCustomErrorHandler | Custom error handler | Uses custom JSON error response instead of default |
TestNewLimiter_Defaults | Default value handling | Negative values are replaced with sensible defaults |
TestLimiter_Adjust | Adjustment with no requests | Rate remains unchanged when no requests are made |
TestLimiter_AdjustHighErrorRate | High error rate adjustment | Rate decreases when error rate exceeds threshold |
TestLimiter_AdjustHighLatency | High latency adjustment | Rate decreases when latency exceeds target |
TestLimiter_AdjustLowLatencyAndErrors | Good performance adjustment | Rate increases when latency is low and errors are minimal |
TestLimiter_AdjustClampToMin | Minimum rate clamping | Rate cannot decrease below configured minimum |
TestLimiter_AdjustClampToMax | Maximum rate clamping | Rate cannot increase above configured maximum |
TestLimiter_AllowTokenRefill | Token refill mechanism | Tokens are refilled over time after exhaustion |
TestLimiter_AllowTokenCap | Token accumulation limit | Tokens are capped at current rate, not unlimited |
TestLimiter_ErrorCounting | Error metric tracking | Requests are counted correctly in statistics |