Fix flaky isLaterThanDays date test - #6691
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. Walkthrough
ChangesDate comparison
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: Merge Risk: ⚪ Minimal · up to The helper now supports an injectable reference time while preserving current production behavior, and deterministic tests cover the comparison boundary. No merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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. A rabbit checks the ticking day Comment |
|
|
🚀 Available in v7.12.0 |


Goal
DateExtensionsTestsflakes on CI. The "exactly as old as specified days" case builds a datenow - 5 daysand expectsisLaterThanDays(5 days)to be false, butisLaterThanDaysreads the clock again internally, so it only holds when both reads land in the same millisecond. Any tick between them flips the result and fails the test.Port of #6690 to develop.
Part of AND-1514
Implementation
now: Date = Date()parameter toisLaterThanDaysso the reference instant can be injected. Production callers use the default and are unchanged.nowand pass it in, removing the wall-clock dependence from the whole suite.Both are
internal, so no public API change.Testing
:stream-chat-android-client:testDebugUnitTest --tests "*DateExtensionsTests"passes; the boundary case is now deterministic.Summary by CodeRabbit