fix(tests): use UTC in get_past_timestamp to fix cooldown tests on non-UTC systems#204
fix(tests): use UTC in get_past_timestamp to fix cooldown tests on non-UTC systems#204timothy-20 wants to merge 2 commits intofrankbria:mainfrom
Conversation
…n-UTC systems The BSD date fallback in get_past_timestamp() used date -r which outputs local time, but the format string hardcoded +00:00 (UTC). On non-UTC systems (e.g. JST+9), parse_iso_to_epoch() interpreted the local time as UTC, producing a future epoch and negative elapsed minutes, causing 5 cooldown tests to always fail. Adding -u flag to date -r ensures UTC output matching the +00:00 suffix. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe test helper Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/unit/test_circuit_breaker_recovery.bats (1)
226-234:⚠️ Potential issue | 🟡 MinorSame timezone bug exists in the clock skew test.
Line 233 uses
date -r "$future_epoch"without the-uflag but hardcodes+00:00in the format string—the same pattern that caused failures inget_past_timestamp. On non-UTC systems, this will output local time with an incorrect UTC suffix.Proposed fix
- future_timestamp=$(date -r "$future_epoch" +"%Y-%m-%dT%H:%M:%S+00:00" 2>/dev/null || skip "Cannot create future timestamp") + future_timestamp=$(date -u -r "$future_epoch" +"%Y-%m-%dT%H:%M:%S+00:00" 2>/dev/null || skip "Cannot create future timestamp")🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/unit/test_circuit_breaker_recovery.bats` around lines 226 - 234, The test "Clock skew (negative elapsed time) stays OPEN safely" creates a future timestamp using date -r without forcing UTC which leads to a wrong "+00:00" suffix on non‑UTC systems; update the fallback command that sets future_timestamp (the date -r "$future_epoch" +"%Y-%m-%dT%H:%M:%S+00:00" call) to produce UTC output (e.g., add the -u flag or otherwise format in UTC) so the timestamp and its "+00:00" suffix are consistent across timezones.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@tests/unit/test_circuit_breaker_recovery.bats`:
- Around line 226-234: The test "Clock skew (negative elapsed time) stays OPEN
safely" creates a future timestamp using date -r without forcing UTC which leads
to a wrong "+00:00" suffix on non‑UTC systems; update the fallback command that
sets future_timestamp (the date -r "$future_epoch" +"%Y-%m-%dT%H:%M:%S+00:00"
call) to produce UTC output (e.g., add the -u flag or otherwise format in UTC)
so the timestamp and its "+00:00" suffix are consistent across timezones.
Apply the same -u flag fix to the clock skew test's BSD date fallback at L233, matching the get_past_timestamp fix at L96. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Fix cooldown timer tests that fail on non-UTC systems (e.g., JST, EST) by using UTC in
get_past_timestamp.The
get_past_timestamphelper generates ISO timestamps for testing cooldown expiration. Without explicit UTC, the timestamp uses the local timezone, butparse_iso_to_epochexpects UTC. This mismatch causes cooldown tests to incorrectly pass or fail depending on the system timezone.Changes
tests/unit/test_circuit_breaker_recovery.bats— add-uflag todatecommand inget_past_timestampTest plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes