feat(yazi): implement PlanForce to reinstall all packages

This commit is contained in:
MDietermann
2026-04-14 22:00:42 +02:00
parent edfff22bac
commit abd0a617e2
2 changed files with 35 additions and 2 deletions

View File

@@ -110,4 +110,30 @@ func TestVerifyAfterApply(t *testing.T) {
}
}
func TestPlanForceReinstallsAllPackages(t *testing.T) {
r := &fakeRunner{installed: map[string]bool{"yazi": true}}
m := New([]string{"yazi"}, platform.NewPacman(r))
plan, err := m.PlanForce(context.Background())
if err != nil {
t.Fatalf("PlanForce: %v", err)
}
if plan.IsEmpty() {
t.Fatal("force plan must not be empty even when packages are installed")
}
for _, a := range plan.Actions {
if err := a.Exec(context.Background()); err != nil {
t.Fatalf("Exec: %v", err)
}
}
sawReinstall := false
for _, c := range r.runCalls {
if len(c) >= 4 && c[0] == "sudo" && c[1] == "pacman" && c[2] == "-S" && c[3] == "--noconfirm" {
sawReinstall = true
}
}
if !sawReinstall {
t.Fatalf("no pacman reinstall call; calls=%v", r.runCalls)
}
}
var _ module.Module = Module{}