← Back to PRs

#12684: Test: add missing unit tests for src/utils modules

by shaynhornik open 2026-02-09 13:44 View on GitHub →
stale
#### Summary Add unit test coverage for three `src/utils` modules that had zero direct tests despite being used in production code: - **`shell-argv.ts`** (`splitShellArgs`) — used in `src/memory/backend-config.ts`, 0 prior tests - **`provider-utils.ts`** (`isReasoningTagProvider`) — used across 4 production files (agent runner, compaction, reply handling), 0 prior tests - **`account-id.ts`** (`normalizeAccountId`) — used in LINE channel accounts, 0 direct tests #### Gap Covered These utilities handle argument parsing, provider detection, and ID normalization. Tests cover: - Happy paths, edge cases (empty/whitespace input, null/undefined) - `splitShellArgs`: single/double quotes, backslash escaping, unterminated quote detection - `isReasoningTagProvider`: exact matches, substring matches, case insensitivity, trimming - `normalizeAccountId`: trimming, empty strings, undefined handling #### Behavior Changes None. Pure test additions — no production code modified. #### Codebase and GitHub Search - Searched for existing test files: `shell-argv.test.ts`, `provider-utils.test.ts`, `account-id.test.ts` — none exist - Confirmed test pattern from `src/utils/boolean.test.ts` - Verified these utils are imported in production code via grep #### Tests - 3 new test files, 27 total test cases - Pattern follows existing `src/utils/boolean.test.ts` conventions lobster-biscuit **Sign-Off** - Submitter effort: manual review of source code + test authoring <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> Adds unit tests for three previously-untested utility modules under `src/utils`: `normalizeAccountId`, `isReasoningTagProvider`, and `splitShellArgs`. The tests follow the existing Vitest co-located test convention (e.g., `src/utils/boolean.test.ts`) and exercise common/edge behaviors like trimming, null/undefined handling, quoted argument parsing, and error cases (unterminated quotes / trailing backslash). No production code is modified; this PR increases coverage around utilities that are referenced by multiple production paths (provider selection logic, argument parsing, and channel account ID normalization). <h3>Confidence Score: 5/5</h3> - This PR is safe to merge; it only adds test coverage with no production behavior changes. - Reviewed the added tests against the current implementations of `normalizeAccountId`, `isReasoningTagProvider`, and `splitShellArgs`. Assertions match actual behavior, and no changes touch runtime code paths. Only minor issue is a misleading test description in `shell-argv.test.ts` (assertion is fine, wording is inconsistent). - src/utils/shell-argv.test.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs