test: improve cmd coverage from 63.4% to 67.6%#68
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves test coverage for the cmd/ package by adding new table-driven tests around key CLI behaviors and HTTP response helpers, and tightens CI by raising the enforced coverage floor.
Changes:
- Add new tests for
cmd/skill.gosubcommand behavior (usage output, list/show output, init idempotency). - Add new tests for
cmd/serve.goJSON and error response helpers. - Extend
cmd/drift_test.goto coverresolveCodePathsglob cleanup and fallback behavior; raise CI coverage floor to 55%.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cmd/skill_test.go | Adds stdout-based tests for skill CLI usage/list/show/init behaviors. |
| cmd/serve_test.go | Adds tests validating JSON/error response helpers (headers, status codes, JSON validity). |
| cmd/drift_test.go | Adds coverage for resolveCodePaths configured-path cleanup and guessed-path fallback. |
| .github/workflows/ci.yml | Raises enforced coverage floor from 50.0% to 55.0%. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| func TestRunSkillList_PrintsBuiltinSkills(t *testing.T) { | ||
| root := t.TempDir() | ||
|
|
||
| out := captureOutput(func() { | ||
| runSkillList(root) | ||
| }) |
There was a problem hiding this comment.
These tests invoke runSkillList/runSkillShow which call skills.LoadSkills(root). LoadSkills also reads global skills from the user’s home directory (~/.codemap/skills), so local developer environments with custom/overriding skills can change the output and make these assertions flaky (e.g., no remaining "[builtin]" lines or "Source: builtin"). Consider making the tests hermetic by setting HOME (and on Windows USERPROFILE) to t.TempDir() (or otherwise disabling global skill discovery) before running the commands.
| tests := []struct { | ||
| name string | ||
| subsystem string | ||
| paths map[string][]string | ||
| wantPrefix string | ||
| }{ | ||
| { | ||
| name: "configured path strips globs", |
There was a problem hiding this comment.
The field name wantPrefix is a bit misleading here: the assertion checks for an exact match (p == tt.wantPrefix) rather than a prefix. Consider renaming it to something like wantPath/wantEntry (or update the assertion to actually check a prefix) to keep the test intent clear.
Summary
cmd/skill.gobehaviors (RunSkillusage, list/show output, init idempotency)cmd/serve.goJSON/error response helperscmd/drift_test.gocoverage forresolveCodePathsglob-cleanup/fallback behavior50.0to55.0in.github/workflows/ci.ymlCoverage
cmd/TOTALValidation
go test -race -coverprofile=coverage.out ./...go vet ./...gofmt -l ._test.gofiles plus CI coverage floor update