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)
| 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. |
| 133 | func 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, ®) |
| 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. |
nothing calls this directly
no test coverage detected