Skip to content

FIX: Make countdown tests deterministic on Windows - #1

Merged
merefield merged 1 commit into
mainfrom
agent/fix-windows-countdown-test
Aug 10, 2026
Merged

merefield merged 1 commit into
mainfrom
agent/fix-windows-countdown-test

Conversation

@merefield

Copy link
Copy Markdown
Owner

Summary

  • separate countdown formatting from the system clock
  • test countdown boundaries with a fixed timestamp
  • assert the mathematically correct exact values for long and short durations

Root cause

The test constructed its deadline from one time.Now() call while production
formatting used another through time.Until. Windows can return the same coarse
clock tick for both calls, leaving the deadline exactly 125 hours away
(5D 05:00), while finer-resolution runners observed a tiny elapsed interval
and 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 .

@merefield merefield changed the title Make countdown tests deterministic on Windows FIX: Make countdown tests deterministic on Windows Aug 10, 2026
@merefield
merefield marked this pull request as ready for review August 10, 2026 16:49
@merefield
merefield requested a lite review from Copilot August 10, 2026 16:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 countdown to delegate to a new countdownFrom(now, at) helper for clock injection.
  • Updates TestTimeFormatting to use a fixed now (time.Unix(...)) instead of time.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.

@merefield
merefield merged commit 2cbcead into main Aug 10, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants