Commit graph

3 commits

Author SHA1 Message Date
jedarden
f878bf4f6e test(ratelimiter): verify TestAdaptiveRateLimiter_BasicState passes all acceptance criteria 2026-07-02 11:53:23 -04:00
jedarden
88358f949a test(ratelimiter): add basic state and bounds tests for AdaptiveRateLimiter
Add table-driven unit tests covering:
- Initial rate starts at ceiling (TestAdaptiveRateLimiter_BasicState)
- Rate never drops below minRate (TestAdaptiveRateLimiter_BasicBounds)
- Rate never exceeds maxRate (TestAdaptiveRateLimiter_BasicBounds)
- Reset() restores initial rate and ceiling (TestAdaptiveRateLimiter_BasicReset)
- getCurrentRate() returns expected values (TestAdaptiveRateLimiter_BasicGetCurrentRate)
- Edge cases: minRate==maxRate, zero ceiling (TestAdaptiveRateLimiter_BasicEdgeCases)

Tests complete in <5ms without sleep calls using injected window duration.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-02 11:47:57 -04:00
jedarden
ee39121cd9 test(ratelimiter): make AdaptiveRateLimiter testable via window duration injection
Add NewAdaptiveRateLimiterWithWindow constructor for test-only refactor:
- Production code uses NewAdaptiveRateLimiter with default 30s window
- Tests can inject shorter durations (e.g., 100ms) for fast execution
- No behavior changes to production rate limiting logic

Acceptance criteria:
- NewAdaptiveRateLimiterWithWindow accepts configurable window duration
- Production callers continue using default 30s window
- Tests can inject millisecond-scale windows for fast iteration
- No changes to rate limiting logic or defaults

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-02 10:55:06 -04:00