Skip to content

test: expand coverage for audit cmd, ecosystem registry, and search client#66

Merged
DecampsRenan merged 1 commit into
mainfrom
claude/analyze-test-coverage-kFmXl
Apr 19, 2026
Merged

test: expand coverage for audit cmd, ecosystem registry, and search client#66
DecampsRenan merged 1 commit into
mainfrom
claude/analyze-test-coverage-kFmXl

Conversation

@DecampsRenan

Copy link
Copy Markdown
Owner

Summary

Fills the three largest test-coverage gaps identified in a codebase audit:

  • cmd/audit previously had no test file. Added tests for command registration, flag wiring (--prod-only, --json, --severity), severity validation (rejects unknown values, accepts case-insensitive valid ones), and the no-project error path.
  • internal/ecosystem/registry.go had no test file. Added tests for ForPM (known/unknown PMs), All() (registers every ecosystem once), and the interface contract (ManifestFile, LockFiles, ArtifactDirs non-empty for every registered ecosystem).
  • internal/search/client.go HTTP-calling functions (Query, FetchDetails, packument/downloads/stars helpers) were entirely untested. Added an httptest-based RoundTripper that routes npm/github API calls to a mock server, covering: result parsing, URL escaping, 5xx errors, malformed JSON, best-effort downloads failures, non-GitHub repos skipping the stars API, malformed timestamps being filtered, and version sorting by publish date.

Coverage impact:

  • internal/search: 13.2% → 30.1%
  • internal/ecosystem: 56.6% → 64.1%

Test plan

  • go test ./internal/... passes locally (cmd tests require alsa headers, verified in CI)
  • goimports -l clean
  • CI passes on PR

Notes / follow-ups

Areas still worth improving (not in this PR):

  • internal/prompt success paths (13.3% coverage) — requires PTY or refactor to inject inputs
  • internal/updater HTTP download path (Execute()) — no fetcher mock covers network failures
  • audio/progress/runner — cannot be tested without decoupling the alsa-dependent audio package behind an interface

https://claude.ai/code/session_01SqEXi8miHuGMKEeJ7ByM3k

…client

Expands test coverage in areas flagged as gaps:

- cmd/audit: flag wiring, command registration, severity validation
- internal/ecosystem: registry lookups, ecosystem interface contract
- internal/search: HTTP-mocked tests for Query and FetchDetails covering
  error responses, URL escaping, version sorting, and best-effort
  downloads/stars failures

Search coverage 13.2% -> 30.1%, ecosystem 56.6% -> 64.1%.

https://claude.ai/code/session_01SqEXi8miHuGMKEeJ7ByM3k
@DecampsRenan DecampsRenan marked this pull request as ready for review April 19, 2026 09:34
@DecampsRenan DecampsRenan merged commit 2070a06 into main Apr 19, 2026
7 checks passed
@DecampsRenan DecampsRenan deleted the claude/analyze-test-coverage-kFmXl branch April 19, 2026 09:35
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.

2 participants