Skip to content

test(harness-search): exercise search() success + failure branches via injected runner#280

Merged
eyelock merged 1 commit into
developfrom
refactor/harness-search-service-di
May 5, 2026
Merged

test(harness-search): exercise search() success + failure branches via injected runner#280
eyelock merged 1 commit into
developfrom
refactor/harness-search-service-di

Conversation

@eyelock
Copy link
Copy Markdown
Owner

@eyelock eyelock commented May 5, 2026

Summary

`HarnessSearchService` already accepts `YNHCommandRunner` and `YNHDetectorProtocol` via init (Phase 9d/9 protocol work landed earlier), but every existing test falls through the `.missing` detector guard — so the entire `search()` body (argument construction, env override, command result decode, error paths) was uncovered. Plan-2 flagged this as the easy win.

This PR adds a `StubYNHCommandRunner` test double and nine tests covering the success and failure branches of `search()`. No production code changes.

What's tested

  • Result decoding from canned JSON
  • Empty-query "browse all" arg shape (`search --format json`, no positional)
  • Whitespace-only query treated as browse
  • Non-zero exit code → error
  • Malformed JSON → error
  • Runner throws → error
  • `ynhHomeOverride` propagates to subprocess environment
  • Subsequent search call cancels the previous (debounce path)

Numbers

  • Tests: 1705 → 1713 (+8 net new; existing 9 still pass)
  • File coverage: was 68% per plan-2 (Apr 22). Should now hit `search` happy + sad paths fully.

Out of scope

The other items from the plan-2 "needs architecture" table are filed as #273#279.

Test plan

CI is sufficient — pure-test PR with no production code changes.

🤖 Generated with Claude Code

…a injected runner

`HarnessSearchService` already accepts a `YNHCommandRunner` and
`YNHDetectorProtocol` via init, but the existing tests all fall through
the `.missing` detector guard — leaving the entire `search()` body
(arg construction, env override, command result decode, error paths)
uncovered.

Adds a `StubYNHCommandRunner` test double and nine tests covering:
- result decoding from canned JSON
- empty-query "browse all" arg shape
- whitespace-only query treated as browse
- non-zero exit code → error
- malformed JSON → error
- runner throws → error
- `ynhHomeOverride` propagates to environment
- subsequent search call cancels the previous (debounce)

Coverage moves from "init + reset + .missing-guard only" to the full
success path. Closes the easy-win line item from
`.claude/plans/2026-04-22-test-integration-initial-handover.md`
(plan-2 table at line 172).

Tests: 1705 → 1713 (+8 net new; the existing 9 still pass).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@eyelock eyelock merged commit 16c376f into develop May 5, 2026
7 checks passed
@eyelock eyelock deleted the refactor/harness-search-service-di branch May 5, 2026 06:22
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.

1 participant