feat(hello): implement PlanForce placeholder to rewrite marker

This commit is contained in:
MDietermann
2026-04-14 21:57:51 +02:00
parent 372a6598fe
commit bd5c34f293
2 changed files with 42 additions and 2 deletions

View File

@@ -55,3 +55,31 @@ func TestHelloFullLifecycle(t *testing.T) {
t.Fatalf("content = %q", data)
}
}
func TestHelloPlanForceNonEmpty(t *testing.T) {
path := filepath.Join(t.TempDir(), "hello.ok")
m := Module{Path: path}
// Even after marker is present, force plan must run.
if err := os.WriteFile(path, []byte(markerContent), 0o644); err != nil {
t.Fatal(err)
}
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")
}
for _, a := range plan.Actions {
if err := a.Exec(context.Background()); err != nil {
t.Fatalf("Exec: %v", err)
}
}
data, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
if string(data) != markerContent {
t.Fatalf("content after force = %q", data)
}
}