refactor(cli): add IO-seam test overrides, raise coverage 58.3% → 72.9%#75
Merged
Conversation
Background internal/cli stopped at 66.2% after PR #72 because cobra RunE functions read CWD via auditDir() (improve.go) and HOME via defaultStateDir() (autoresearch.go) directly. Tests had to chdir the whole process, which broke parallel-test isolation and made driving multiple commands in one test binary fragile. IO-seam refactor Two package-level test seams replace the chdir gymnastics: - internal/cli/improve.go: auditDirOverride is a package var. The production auditDir() function checks it first; when empty falls through to the os.Getwd() path. - internal/cli/autoresearch.go: stateDirOverride mirrors the same pattern for defaultStateDir(), still honouring VXD_STATE_DIR and $HOME when the override is empty. improve_commands_test.go now uses withAuditDir() + the seedAuditDir() helper instead of withChdir. Existing tests still pass, no production behaviour changes. New test coverage autoresearch_io_test.go — loadConfigForAutoresearch (missing file, parse error, valid YAML), openEventStore (success + unwritable parent), countWinsLosses (empty bank). backup_logs_test.go — runBackup end-to-end against a seeded vxd.yaml with state_dir in t.TempDir(); runLogs missing-file error path and successful-stream path. db_helpers_test.go — findDBByNameOrID (by name, by ID, not found, empty slice), isTerminal (buffer + regular file both rejected), dbProviderFor / dockerProviderFor failure paths. db_subcommands_test.go — every vxd db subcommand drives its early branch with devdb disabled (list, connect, sql, schema, delete with and without --confirm, gc no-op, ping, template list, template create). devdb_provider_test.go — newDevDBProvider (null default + explicit, docker, ghost without API key, unknown provider). extra_commands_test.go — Execute() --help path, autoresearch stop / evolve / start (dry-run) / hypotheses / status against empty store. resume_helpers_test.go — pickRuntime (prefers claude-code, falls back to any, empty map), newDevDBLifecycle (disabled, docker, bad ghost), runDevDBOrphanRecovery early-return, runResume no-active-requirements path. req_helpers_test.go — buildPlanningClient (anthropic with API key, anthropic no creds, godmode propagation, openai/google no creds). Coverage delta internal/cli: 58.3% → 72.9% (+14.6 points) Falls short of the 80% target. The remaining gap is dominated by cobra RunE flows that need live docker / gh / claude CLI to reach their happy paths; closing the rest of the way requires fakes for those subsystems rather than more test code at this layer. CLAUDE.md records the remaining work as a separate follow-up. Verified go build ./..., go vet ./..., go test ./... -count=1 — all 30 packages pass. golangci-lint run --timeout=5m ./... — 0 issues.
CI fails preflight earlier ("aborting: critical pre-flight issues")
than the local box does, and the previous test only allowed a fixed
list of substrings. The wired-up entry point either errors or succeeds
— that's the only invariant the test actually needs.
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
Closes the cli IO-seam follow-up tracked in CLAUDE.md "Still open" since PR #72. Two new package-level test seams replace the chdir-based test setup; the production code path is unchanged. Existing tests continue to pass.
Coverage delta
Falls short of the 80% target. The remaining gap is dominated by cobra `RunE` flows that require live docker / gh / claude CLI to reach their happy paths; closing the rest of the way needs fakes for those subsystems rather than more test code at this layer. CLAUDE.md records the remaining work as a separate follow-up.
IO-seam refactor
New test files (8)
Test plan