MCPcopy Create free account
hub / github.com/Facets-cloud/flow / TestAutoExecFinalizesCompleted

Function TestAutoExecFinalizesCompleted

internal/app/auto_test.go:201–232  ·  view source on GitHub ↗

TestAutoExecFinalizesCompleted: when the headless session self-completes (task ends up 'done' and the runner returns nil), __auto-exec records 'completed' and clears the pid.

(t *testing.T)

Source from the content-addressed store, hash-verified

199// (task ends up 'done' and the runner returns nil), __auto-exec records
200// 'completed' and clears the pid.
201func TestAutoExecFinalizesCompleted(t *testing.T) {
202 setupFlowRoot(t)
203 seedTask(t, "auto-task")
204 seedRunningAuto(t, "auto-task", 4242)
205
206 stubAutoRunner(t, func(h harness.Harness, sessionID, prompt string, opts harness.LaunchOpts) error {
207 // Simulate the session calling `flow done` on itself.
208 db := openFlowDB(t)
209 if _, err := db.Exec(`UPDATE tasks SET status='done' WHERE slug='auto-task'`); err != nil {
210 return err
211 }
212 return nil
213 })
214
215 if rc := cmdAutoExec([]string{"auto-task"}); rc != 0 {
216 t.Fatalf("cmdAutoExec rc=%d, want 0", rc)
217 }
218 db := openFlowDB(t)
219 task, err := flowdb.GetTask(db, "auto-task")
220 if err != nil {
221 t.Fatal(err)
222 }
223 if task.AutoRunStatus.String != "completed" {
224 t.Errorf("auto_run_status = %q, want completed", task.AutoRunStatus.String)
225 }
226 if !task.AutoRunFinished.Valid {
227 t.Error("auto_run_finished should be set after finalize")
228 }
229 if task.AutoRunPID.Valid {
230 t.Errorf("auto_run_pid should be cleared after finalize; got %d", task.AutoRunPID.Int64)
231 }
232}
233
234// TestAutoExecFinalizesDead: a runner error (or a session that never marks
235// itself done) finalizes as 'dead'.

Callers

nothing calls this directly

Calls 8

GetTaskFunction · 0.92
setupFlowRootFunction · 0.85
seedTaskFunction · 0.85
seedRunningAutoFunction · 0.85
stubAutoRunnerFunction · 0.85
openFlowDBFunction · 0.85
cmdAutoExecFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected