← Back to PRs

#4095: Test/add format duration tests

by TechWizard9999 open 2026-01-29 17:28 View on GitHub →
Closes #4025 ## Summary Adds missing unit tests for `src/infra/format-duration.ts` to ensure accurate time formatting (e.g., "1.5s", "500ms") across the CLI and logs. ## Changes - **src/infra/format-duration.test.ts**: New test file covering `formatDurationSeconds` and `formatDurationMs` with edge cases for decimals and unit labels. ## Verification - [x] Ran `npx vitest run format-duration` - [x] Verified 11/11 tests passed <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> Adds new unit tests for duration formatting helpers (`formatDurationSeconds`/`formatDurationMs`), plus additional regression coverage for transient network error classification and backoff/sleep utilities. The runtime behavior change in `isTransientNetworkError` broadens the set of `TypeError("fetch failed")` cases treated as transient when a cause exists but is not classified as fatal or configuration-related, aligning with the intent to avoid crashing the gateway on undici fetch failures. <h3>Confidence Score: 4/5</h3> - This PR is generally safe to merge; changes are mostly tests with a small, targeted error-classification tweak. - I reviewed the changed files and the related implementations. The only notable issue is a probabilistic jitter test that could be flaky in CI; otherwise the additions are straightforward and align with existing behavior (formatting outputs, abort handling, and transient fetch failure handling). - src/infra/backoff.test.ts (jitter test determinism) <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs