MCPcopy
hub / github.com/labstack/echo / TestNewRateLimiterMemoryStore

Function TestNewRateLimiterMemoryStore

middleware/rate_limiter_test.go:414–433  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

412}
413
414func TestNewRateLimiterMemoryStore(t *testing.T) {
415 testCases := []struct {
416 rate float64
417 burst int
418 expiresIn time.Duration
419 expectedExpiresIn time.Duration
420 }{
421 {1, 3, 5 * time.Second, 5 * time.Second},
422 {2, 4, 0, 3 * time.Minute},
423 {1, 5, 10 * time.Minute, 10 * time.Minute},
424 {3, 7, 0, 3 * time.Minute},
425 }
426
427 for _, tc := range testCases {
428 store := NewRateLimiterMemoryStoreWithConfig(RateLimiterMemoryStoreConfig{Rate: tc.rate, Burst: tc.burst, ExpiresIn: tc.expiresIn})
429 assert.Equal(t, tc.rate, store.rate)
430 assert.Equal(t, tc.burst, store.burst)
431 assert.Equal(t, tc.expectedExpiresIn, store.expiresIn)
432 }
433}
434
435func TestRateLimiterMemoryStore_FractionalRateDefaultBurst(t *testing.T) {
436 store := NewRateLimiterMemoryStoreWithConfig(RateLimiterMemoryStoreConfig{

Callers

nothing calls this directly

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…