Repository navigation
FIX: Make countdown tests deterministic on Windows - #1
Merged
Merged
Conversation
merefield
marked this pull request as ready for review
August 10, 2026 16:49
There was a problem hiding this comment.
Pull request overview
This PR makes the countdown formatting tests deterministic across platforms by separating the countdown calculation from the system clock and updating the tests to use a fixed reference timestamp, eliminating timing/clock-resolution flakiness (notably on Windows).
Changes:
- Refactors
countdownto delegate to a newcountdownFrom(now, at)helper for clock injection. - Updates
TestTimeFormattingto use a fixednow(time.Unix(...)) instead oftime.Now(). - Tightens assertions to check exact expected formatted outputs for long and short durations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/ui/view.go | Adds countdownFrom and routes countdown through it to decouple formatting from the system clock. |
| internal/ui/view_test.go | Rewrites countdown tests to use a fixed timestamp and assert exact expected strings. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause
The test constructed its deadline from one
time.Now()call while productionformatting used another through
time.Until. Windows can return the same coarseclock tick for both calls, leaving the deadline exactly 125 hours away
(
5D 05:00), while finer-resolution runners observed a tiny elapsed intervaland produced
5D 04:59.Impact
Countdown behavior is unchanged in production, but the cross-platform test no
longer depends on scheduler timing or clock resolution.
Validation
go test ./...go test -race -cover ./...go vet ./...gofmt -l .