Skip to content

Improve test coverage#9

Merged
serroba merged 1 commit into
mainfrom
dev
Jan 1, 2026
Merged

Improve test coverage#9
serroba merged 1 commit into
mainfrom
dev

Conversation

@serroba
Copy link
Copy Markdown
Owner

@serroba serroba commented Jan 1, 2026

No description provided.

Copilot AI review requested due to automatic review settings January 1, 2026 05:04
@serroba serroba merged commit 2399c4a into main Jan 1, 2026
5 checks passed
@serroba serroba deleted the dev branch January 1, 2026 05:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves test coverage for the leaky bucket rate limiter by introducing clock injection for time-dependent testing. The changes enable deterministic testing of time-sensitive behavior without relying on actual time delays.

Key changes:

  • Added clock abstraction to LeakyLimiter for testability
  • Added three new test cases covering drain behavior and clock edge cases
  • Changed test struct fields from exported to unexported (style consistency)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
bucket/leaky.go Adds clock interface injection to LeakyLimiter with a new constructor for testing
bucket/leaky_test.go Adds three new test cases for clock backward movement, full drain, and partial drain behaviors
registry/registry_test.go Changes struct fields from exported to unexported in test-only configuration types

After thoroughly reviewing the changes, I found no issues with this pull request. The changes are well-implemented:

  1. bucket/leaky.go: The clock abstraction follows the same pattern already established in bucket/token.go, maintaining consistency across the codebase.

  2. bucket/leaky_test.go: The new tests properly leverage the existing testClock type from bucket/token_test.go (both in package bucket_test), and they test important edge cases:

    • Clock going backwards (should not drain)
    • Full drain after time advancement
    • Partial drain with fractional time advancement
  3. registry/registry_test.go: The change from exported to unexported fields is a stylistic improvement for test-only structs. Since the struct literals are used within the same package, this works correctly and is a common Go idiom for internal test types.

The PR successfully achieves its goal of improving test coverage with clean, maintainable code.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants