Repository navigation
fix(rotation): use toBeCloseTo for time-dependent token assertion - #556
Conversation
getTokens() applies sub-millisecond regeneration between consume calls, causing exact equality to flake. Aligns with other time-dependent assertions in the same file. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (1)
WalkthroughA test assertion in the Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
Greptile SummaryThis PR fixes a flaky test assertion in Confidence Score: 5/5Safe to merge — single test assertion fix with no production code changes. The change is a one-line test fix that aligns an outlier assertion with the established No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant T as Test
participant TBT as TokenBucketTracker
participant Clock as Date.now()
T->>TBT: new TokenBucketTracker({ initialTokens: 50 })
T->>TBT: consume(0, 10) → true
TBT->>Clock: Date.now() → T1
Note over TBT: stored: { tokens: 40, lastUpdated: T1 }
T->>TBT: consume(0, 10) → true
TBT->>Clock: getTokens calls Date.now() → T2
Note over TBT: tokens = 40 + regen(T2-T1) ≈ 40
TBT->>Clock: Date.now() → T2
Note over TBT: stored: { tokens: ≈30, lastUpdated: T2 }
T->>TBT: consume(0, 10) → true
TBT->>Clock: getTokens calls Date.now() → T3
Note over TBT: tokens = ≈30 + regen(T3-T2) ≈ 30
TBT->>Clock: Date.now() → T3
Note over TBT: stored: { tokens: ≈20, lastUpdated: T3 }
T->>TBT: getTokens(0)
TBT->>Clock: Date.now() → T4
Note over TBT: returns ≈20 + regen(T4-T3)
TBT-->>T: ≈20.000x (not exactly 20)
Note over T: toBeCloseTo(20, 2) ✓ passes within ±0.005
Reviews (1): Last reviewed commit: "fix(rotation): use toBeCloseTo for time-..." | Re-trigger Greptile |
getTokens() applies sub-millisecond regeneration between consume calls, causing exact equality to flake. Aligns with other time-dependent assertions in the same file.