Files
simslim-mirror/status_test.go
Interlap ffd3a13d34 refactor: split into an importable library and a cmd/simslim CLI (#14)
The repo root becomes `package simslim`, an importable library holding every
piece of slimming logic; the CLI moves to `cmd/simslim`. Previously everything
was `package main`, so nothing here could be imported at all.

The library carries no external dependencies — urfave/cli stays on the CLI side,
along with all terminal-facing code: the interactive profile wizard, writeJSON,
truncate/humanBytes, fatal and usage. The library never writes to stdout; it
returns values and reports progress through the Reporter callback.

Renames forced by collisions with existing types: status() -> ReadStatus,
statusForDevice() -> ReadStatusForDevice, diskCleanupPlan() -> PlanDiskCleanup.
The shutdown/boot timeouts move to simctl.go as ShutdownTimeout/BootTimeout.

`go install` gains a path element: github.com/mobai-app/simslim/cmd/simslim.
The installed binary is still named simslim, and -X main.version still applies.
packaging/homebrew/simslim.rb.in is updated to match, since std_go_args passes
no package path.

Verified live against a real simulator: list, profiles, status, doctor, size,
disk-plan, measure, boot, shutdown, on, off, on --except, on --profile, clone,
rename, delete and the interactive wizard all behave identically to the previous
build. JSON output, human output, help text and exit codes are unchanged.
2026-07-23 12:39:20 +02:00

44 lines
1.1 KiB
Go

package simslim
import "testing"
func TestDroppedCategories(t *testing.T) {
search, ok := CategoryByID("search")
if !ok {
t.Fatal("search category not found")
}
disabled := map[string]bool{
search.Labels[0]: true,
search.Labels[1]: true,
"com.apple.assistantd": true,
"com.apple.not-a-managed-d": true,
}
got := DroppedCategories(disabled)
byID := map[string]DroppedCategory{}
for _, c := range got {
byID[c.ID] = c
}
if len(got) != 2 {
t.Fatalf("dropped categories = %d, want 2 (search, siri)", len(got))
}
if labels := byID["search"].Labels; len(labels) != 2 {
t.Errorf("search dropped labels = %v, want 2", labels)
}
if labels := byID["siri"].Labels; len(labels) != 1 || labels[0] != "com.apple.assistantd" {
t.Errorf("siri dropped labels = %v, want [com.apple.assistantd]", labels)
}
for _, c := range got {
if c.Downside == "" {
t.Errorf("dropped category %q has no downside", c.ID)
}
}
}
func TestDroppedCategoriesEmpty(t *testing.T) {
if got := DroppedCategories(map[string]bool{}); len(got) != 0 {
t.Errorf("DroppedCategories(stock) = %v, want empty", got)
}
}