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

Function TestCmdDoAutoRefusesWhenAlreadyRunning

internal/app/auto_test.go:152–172  ·  view source on GitHub ↗

TestCmdDoAutoRefusesWhenAlreadyRunning: a second --auto launch while a prior run is still 'running' (live pid) is refused without --force.

(t *testing.T)

Source from the content-addressed store, hash-verified

150// TestCmdDoAutoRefusesWhenAlreadyRunning: a second --auto launch while a
151// prior run is still 'running' (live pid) is refused without --force.
152func TestCmdDoAutoRefusesWhenAlreadyRunning(t *testing.T) {
153 setupFlowRoot(t)
154 seedTask(t, "auto-task")
155 stubITerm(t)
156 stubAutoLauncher(t, 4242)
157
158 // Mark the pid alive so the running-guard fires.
159 oldAlive := processAlive
160 processAlive = func(pid int) bool { return true }
161 t.Cleanup(func() { processAlive = oldAlive })
162
163 if rc := cmdDo([]string{"auto-task", "--auto"}); rc != 0 {
164 t.Fatalf("first --auto rc=%d, want 0", rc)
165 }
166 if rc := cmdDo([]string{"auto-task", "--auto"}); rc != 1 {
167 t.Errorf("second --auto rc=%d, want 1 (already running)", rc)
168 }
169 if rc := cmdDo([]string{"auto-task", "--auto", "--force"}); rc != 0 {
170 t.Errorf("--auto --force rc=%d, want 0 (override running guard)", rc)
171 }
172}
173
174// stubAutoRunner replaces autoRunner with fn.
175func stubAutoRunner(t *testing.T, fn func(h harness.Harness, sessionID, prompt string, opts harness.LaunchOpts) error) {

Callers

nothing calls this directly

Calls 5

setupFlowRootFunction · 0.85
seedTaskFunction · 0.85
stubITermFunction · 0.85
stubAutoLauncherFunction · 0.85
cmdDoFunction · 0.85

Tested by

no test coverage detected