TestCmdDoBackgroundAlreadyRunning: re-running while the session is alive in the registry must NOT spawn or resume — just report.
(t *testing.T)
| 170 | // TestCmdDoBackgroundAlreadyRunning: re-running while the session is alive |
| 171 | // in the registry must NOT spawn or resume — just report. |
| 172 | func TestCmdDoBackgroundAlreadyRunning(t *testing.T) { |
| 173 | setupFlowRoot(t) |
| 174 | seedTask(t, "bgt") |
| 175 | stubBGMode(t) |
| 176 | stubITerm(t) |
| 177 | reg := bgAgentsJSON(bgFullSID) |
| 178 | c := stubBGCommand(t, ®) |
| 179 | |
| 180 | if rc := cmdDo([]string{"bgt"}); rc != 0 { // fresh spawn, binds bgFullSID |
| 181 | t.Fatalf("first cmdDo rc=%d", rc) |
| 182 | } |
| 183 | if rc := cmdDo([]string{"bgt"}); rc != 0 { // session still alive |
| 184 | t.Fatalf("second cmdDo rc=%d", rc) |
| 185 | } |
| 186 | if c.spawn != 1 { |
| 187 | t.Errorf("spawn calls = %d, want 1 (no re-spawn when already running)", c.spawn) |
| 188 | } |
| 189 | if c.resume != 0 { |
| 190 | t.Errorf("resume calls = %d, want 0 (already running, not gone)", c.resume) |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | // TestCmdDoBackgroundResumeWhenGone: a bound session ABSENT from the |
| 195 | // registry is brought back via --bg --resume <oldid>, and because --bg |
nothing calls this directly
no test coverage detected