test(coverage): add targeted tests to raise per-package coverage gates

- internal/homesick/version: new version_test.go covers String constant
  and semver format validation
- internal/homesick/cli: add list, generate, clone, status, diff, and
  git-repo helper tests; coverage raised from 62.5% to 71.2%
- internal/homesick/core: new helpers_test.go covers runGit pretend,
  actionVerb, sayStatus, unlinkPath, linkPath, readSubdirs,
  matchesIgnoredDir, confirmDestroy, ExecAll edge cases, and
  Link/Unlink default castle wrappers; core_test.go and pull_test.go
  extended with New constructor and PullAll quiet-mode tests;
  exec_test.go extended with ExecAll no-repos-dir and error-wrap tests;
  coverage raised from 75.6% to 80.2%
This commit is contained in:
Micheal Wilkinson
2026-03-21 20:13:31 +00:00
parent 4b54a45a76
commit 5b37057b61
6 changed files with 405 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package core
import (
"bytes"
"path/filepath"
"testing"
)
@@ -47,3 +48,29 @@ func TestDeriveDestination(t *testing.T) {
})
}
}
func TestNewInitializesApp(t *testing.T) {
stdout := &bytes.Buffer{}
stderr := &bytes.Buffer{}
app, err := New(stdout, stderr)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if app == nil {
t.Fatal("expected app instance")
}
if app.Stdout != stdout {
t.Fatal("expected stdout writer to be assigned")
}
if app.Stderr != stderr {
t.Fatal("expected stderr writer to be assigned")
}
if app.HomeDir == "" {
t.Fatal("expected home directory to be set")
}
if app.ReposDir != filepath.Join(app.HomeDir, ".homesick", "repos") {
t.Fatalf("unexpected repos dir: %q", app.ReposDir)
}
}