Repository navigation
fix(entitlement): fix grant recurrence on period start - #4278
Conversation
📝 WalkthroughWalkthroughThis PR refactors grant recurrence handling to properly capture grants recurring at period boundaries. It introduces a ChangesGrant Recurrence at Period Boundaries
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
openmeter/credit/engine/reset_test.go (1)
272-272: Swapcontext.Background()tot.Context()here.This keeps the test lifecycle tied to the test harness instead of spinning up a background context. Since you've got
t *testing.Tavailable in the test function, you get better cancellation semantics and cleaner test teardown this way—it's a small change with nice benefits.Suggested change
- res, err := eng.Run( - context.Background(), + res, err := eng.Run( + t.Context(),🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@openmeter/credit/engine/reset_test.go` at line 272, Replace the call to context.Background() used in the test with the test's cancellable context t.Context(): locate the invocation that currently passes context.Background() (e.g., as an argument to the function under test in reset_test.go) and change it to use t.Context() so the test lifecycle and cancellation are tied to the testing.T instance rather than a background context.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@openmeter/credit/engine/reset_test.go`:
- Line 272: Replace the call to context.Background() used in the test with the
test's cancellable context t.Context(): locate the invocation that currently
passes context.Background() (e.g., as an argument to the function under test in
reset_test.go) and change it to use t.Context() so the test lifecycle and
cancellation are tied to the testing.T instance rather than a background
context.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 25533cdc-16a2-42d2-9c84-df58533eaf3f
📒 Files selected for processing (4)
openmeter/credit/engine/burnphase.goopenmeter/credit/engine/grant.goopenmeter/credit/engine/reset_test.goopenmeter/credit/engine/run.go
Overview
Grants recurring at the period boundary didn't contribute to the starting balance in case it was resolved for the exact period start (at = period.From)
Summary by CodeRabbit
Refactor
Tests