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

Function TestCmdDoBackgroundFreshSpawn

internal/app/background_test.go:133–168  ·  view source on GitHub ↗

TestCmdDoBackgroundFreshSpawn: $FLOW_TERM=bg flow do spawns a bg agent, captures the REAL full session id (not a pre-allocated phantom), records it + harness, flips to in-progress, and opens NO terminal tab.

(t *testing.T)

Source from the content-addressed store, hash-verified

131// agent, captures the REAL full session id (not a pre-allocated phantom),
132// records it + harness, flips to in-progress, and opens NO terminal tab.
133func TestCmdDoBackgroundFreshSpawn(t *testing.T) {
134 setupFlowRoot(t)
135 seedTask(t, "bgt")
136 stubBGMode(t)
137 itermCount, _ := stubITerm(t)
138 reg := bgAgentsJSON(bgFullSID)
139 c := stubBGCommand(t, &reg)
140
141 if rc := cmdDo([]string{"bgt"}); rc != 0 {
142 t.Fatalf("cmdDo (bg) rc=%d, want 0", rc)
143 }
144 if *itermCount != 0 {
145 t.Errorf("terminal spawn count = %d, want 0 (bg opens no tab)", *itermCount)
146 }
147 if c.spawn != 1 {
148 t.Fatalf("bg spawn calls = %d, want 1", c.spawn)
149 }
150 if !containsArg(c.lastSpawn, "--bg") || !pairArg(c.lastSpawn, "--name", "bgt") {
151 t.Errorf("spawn argv wrong: %v", c.lastSpawn)
152 }
153
154 db := openFlowDB(t)
155 task, err := flowdb.GetTask(db, "bgt")
156 if err != nil {
157 t.Fatal(err)
158 }
159 if task.SessionID.String != bgFullSID {
160 t.Errorf("session_id = %q, want captured %q", task.SessionID.String, bgFullSID)
161 }
162 if task.Status != "in-progress" {
163 t.Errorf("status = %q, want in-progress", task.Status)
164 }
165 if !task.Harness.Valid || task.Harness.String != "claude" {
166 t.Errorf("harness = %+v, want claude", task.Harness)
167 }
168}
169
170// TestCmdDoBackgroundAlreadyRunning: re-running while the session is alive
171// in the registry must NOT spawn or resume — just report.

Callers

nothing calls this directly

Calls 11

GetTaskFunction · 0.92
setupFlowRootFunction · 0.85
seedTaskFunction · 0.85
stubBGModeFunction · 0.85
stubITermFunction · 0.85
bgAgentsJSONFunction · 0.85
stubBGCommandFunction · 0.85
cmdDoFunction · 0.85
containsArgFunction · 0.85
pairArgFunction · 0.85
openFlowDBFunction · 0.85

Tested by

no test coverage detected