test: expand coverage for audit cmd, ecosystem registry, and search client#66
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fills the three largest test-coverage gaps identified in a codebase audit:
cmd/auditpreviously 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.gohad no test file. Added tests forForPM(known/unknown PMs),All()(registers every ecosystem once), and the interface contract (ManifestFile,LockFiles,ArtifactDirsnon-empty for every registered ecosystem).internal/search/client.goHTTP-calling functions (Query,FetchDetails, packument/downloads/stars helpers) were entirely untested. Added anhttptest-basedRoundTripperthat 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 -lcleanNotes / follow-ups
Areas still worth improving (not in this PR):
internal/promptsuccess paths (13.3% coverage) — requires PTY or refactor to inject inputsinternal/updaterHTTP download path (Execute()) — no fetcher mock covers network failuresaudio/progress/runner— cannot be tested without decoupling the alsa-dependentaudiopackage behind an interfacehttps://claude.ai/code/session_01SqEXi8miHuGMKEeJ7ByM3k