Fix TestFormatDueDate year-boundary flake

Merged
RO
5mo ago
+28-17

Problem

TestFormatDueDate fails on any run after June, blocking CI on main and every open PR:

Error:    "Sat, Jan 2, 2027" should not contain "2027"
Messages: same-year dates should omit year

The "same year" case built its date with now.AddDate(0, 6, 0) (6 months ahead). From July onward that lands in the next calendar year, so formatDueDate correctly includes the year — and the NotContains(year) assertion fails. It's a latent test bug that started firing as the calendar rolled forward; the production formatDueDate is unaffected.

Fix

Pick a same-year date in the opposite half of the current year (Feb if now is in H2, Nov if now is in H1). That guarantees it stays in the current calendar year and clear of the today/tomorrow/yesterday window no matter when in the year the suite runs.

Verification

  • Before: TestFormatDueDate red (reproduces on clean main).
  • After: TestFormatDueDate and the full internal/tui/workspace/views package green.
  • gofmt/go vet clean.

Summary by cubic

Fixes a flaky TestFormatDueDate and makes it fully deterministic by driving it from a fixed now. Keeps CI green without changing formatDueDate behavior.

  • Bug Fixes
    • Extracted formatDueDateAt(iso, now) and have formatDueDate call it with time.Now() to remove midnight/New‑Year races.
    • Assert the same‑year case using Feb 15 of the current year, safely away from today/tomorrow/yesterday.