`pkg/timeutil/format_test.go` only exercised `FormatDuration`, leaving `FormatDurationMs` and `FormatDurationNs` — both non-trivial (rounding, zero/negative guard, minute+second composition) — covered solely by the thinner, doc-driven `spec_test.go`. The existing test also used manual comparison instead of the `testify/assert` style used elsewhere in the repo.

Author: nexoracontrol-opsCreated Sep 2, 2026Updated Sep 2, 2026

pkg/timeutil/format_test.go only exercised FormatDuration, leaving FormatDurationMs and FormatDurationNs — both non-trivial (rounding, zero/negative guard, minute+second composition) — covered solely by the thinner, doc-driven spec_test.go. The existing test also used manual comparison instead of the testify/assert style used elsewhere in the repo.

Test-only change; format.go is untouched.

Changes

  • TestFormatDurationMs (new) — boundaries 0, 999, 1000, 59999, 60000, multi-minute compositions (90000, 125000, 3_600_000), and negative input.
  • TestFormatDurationNs (new) — zero/negative guard (including large negative), rounding boundaries around half-second (499_999_999, 500_000_000, 1_499_999_999, 1_500_000_000), and multi-hour durations.
  • TestFormatDuration — swapped if/t.Errorf for assert.Equal; table and sub-case names unchanged.

Negative ms behavior

FormatDurationMs(-500) falls into the ms < 1000 branch and returns "-500ms". Asserted as-is rather than changed: the function is used for elapsed-time display where negatives shouldn't arise, and altering the guard is a behavior change beyond a test-quality fix. Flagging for reviewer input if the em-dash treatment used by FormatDurationNs is preferred here too.

go
{
	name:     "negative milliseconds",
	ms:       -500,
	expected: "-500ms",
},

Note on spec_test.go

Left in place. It lives in the external timeutil_test package and is intentionally documentation-driven (each case cites a README spec section), so it serves a different purpose than the exhaustive internal tables. The issue's suggestion to consolidate would collapse that distinction — worth a separate discussion if the duplication proves to drift.

  • Fixes #55840

Originally posted by @Copilot in https://github.com/github/gh-aw/pull/55891

Source: actions/starter-workflows