Skip to content

test(ratelimit): cover WithInterceptorLogger and WithRejectedCounter#394

Open
zeevdr wants to merge 1 commit into
mainfrom
issue-300-interceptor-logger-counter-tests
Open

test(ratelimit): cover WithInterceptorLogger and WithRejectedCounter#394
zeevdr wants to merge 1 commit into
mainfrom
issue-300-interceptor-logger-counter-tests

Conversation

@zeevdr
Copy link
Copy Markdown
Member

@zeevdr zeevdr commented May 14, 2026

Summary

  • Both WithInterceptorLogger and WithRejectedCounter had no tests — they could be silently dropped from the wiring without any failure catching it.
  • WithInterceptorLogger is exercised by confirming that a health-check call writes the expected debug log entry to the supplied logger.
  • WithRejectedCounter is exercised by confirming that a rejected unary call increments the counter exactly once, using a lightweight noop-embedded stub that captures Add calls without pulling in the full OTel SDK.

Test plan

  • TestWithInterceptorLogger — health-check call with a zero-capacity limiter passes (exempt), and the custom logger receives the "rate limit exempt" debug entry.
  • TestWithRejectedCounter — non-exempt call with a zero-capacity limiter is rejected with ResourceExhausted, and the counter records exactly 1 increment.
  • Both tests pass under go test ./internal/ratelimit/....
  • make lint passes.

Closes #300

🤖 Generated with Claude Code

…Counter

Both options had no direct test — they could be silently ignored without
any failure. WithInterceptorLogger is verified by checking that health-check
calls produce a debug log entry on the supplied logger. WithRejectedCounter
is verified by checking that a rejected unary call increments the counter
exactly once, using a noop-embedded stub that captures Add calls.

Co-Authored-By: Claude <noreply@anthropic.com>
Closes #300
@zeevdr zeevdr added this to the v0.11.0-alpha.2 milestone May 14, 2026
@zeevdr zeevdr added enhancement New feature or request server Server changes size: S Quick win — a few hours or less priority: P2 Nice-to-have labels May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request priority: P2 Nice-to-have server Server changes size: S Quick win — a few hours or less

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cover WithInterceptorLogger and WithRejectedCounter options

1 participant