Skip to content

test: improve cmd coverage from 63.4% to 67.6%#68

Open
JordanCoin wants to merge 1 commit intomainfrom
automation/test-coverage-cmd-20260403
Open

test: improve cmd coverage from 63.4% to 67.6%#68
JordanCoin wants to merge 1 commit intomainfrom
automation/test-coverage-cmd-20260403

Conversation

@JordanCoin
Copy link
Copy Markdown
Owner

Summary

  • Add focused table-driven tests for cmd/skill.go behaviors (RunSkill usage, list/show output, init idempotency)
  • Add focused table-driven tests for cmd/serve.go JSON/error response helpers
  • Extend cmd/drift_test.go coverage for resolveCodePaths glob-cleanup/fallback behavior
  • Raise CI coverage floor from 50.0 to 55.0 in .github/workflows/ci.yml

Coverage

Scope Before After
cmd/ 63.4% 67.6%
TOTAL 72.7% 73.9%

Validation

  • go test -race -coverprofile=coverage.out ./...
  • go vet ./...
  • gofmt -l .
  • No source files modified, only _test.go files plus CI coverage floor update
  • Coverage floor bumped in CI (50.0 -> 55.0)

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.go subcommand behavior (usage output, list/show output, init idempotency).
  • Add new tests for cmd/serve.go JSON and error response helpers.
  • Extend cmd/drift_test.go to cover resolveCodePaths glob 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.

Comment on lines +41 to +46
func TestRunSkillList_PrintsBuiltinSkills(t *testing.T) {
root := t.TempDir()

out := captureOutput(func() {
runSkillList(root)
})
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +93 to +100
tests := []struct {
name string
subsystem string
paths map[string][]string
wantPrefix string
}{
{
name: "configured path strips globs",
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants