feat(hello): implement PlanForce placeholder to rewrite marker
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user