Files
Willie a8fb965b8b test: add unit tests for sync, install, and server packages
Boost unit test coverage across three core packages:
- internal/sync: 11.6% → 54.6% (discovery, status, checksum, manifest, pull, merge/prune)
- internal/install: 40.7% → 60.0% (meta, ignore, copy, updatable, local install, options, gitignore, source)
- internal/server: 15.1% → 40.0% (health, overview, skills, targets, config, log, trash, sync, collect, check, backup, diff, audit, hub)
2026-02-23 04:18:01 +08:00

42 lines
956 B
Go

package install
import "testing"
func TestShouldInstallAll(t *testing.T) {
tests := []struct {
name string
opts InstallOptions
want bool
}{
{"default", InstallOptions{}, false},
{"all", InstallOptions{All: true}, true},
{"yes", InstallOptions{Yes: true}, true},
{"both", InstallOptions{All: true, Yes: true}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.opts.ShouldInstallAll(); got != tt.want {
t.Errorf("ShouldInstallAll() = %v, want %v", got, tt.want)
}
})
}
}
func TestHasSkillFilter(t *testing.T) {
tests := []struct {
name string
opts InstallOptions
want bool
}{
{"empty", InstallOptions{}, false},
{"with filter", InstallOptions{Skills: []string{"a"}}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.opts.HasSkillFilter(); got != tt.want {
t.Errorf("HasSkillFilter() = %v, want %v", got, tt.want)
}
})
}
}