---------- cwd-matches-work_dir invariant on flow do --here ---------- TestCmdDoHereRefusesWhenTranscriptMissing pins the GH #59 invariant: --here refuses when the harness's on-disk transcript for (work_dir, sid) isn't where future resumes would look. This is the honest check that catches both naive
(t *testing.T)
| 1188 | spawns, _ := stubITerm(t) |
| 1189 | rc := cmdDo([]string{"with-mutex", "--with", "x", "--with-file", p}) |
| 1190 | if rc != 2 { |
| 1191 | t.Errorf("rc=%d, want 2 for mutex violation", rc) |
| 1192 | } |
| 1193 | if atomic.LoadInt64(spawns) != 0 { |
| 1194 | t.Errorf("mutex violation should not spawn: %d", *spawns) |
| 1195 | } |
| 1196 | } |
| 1197 | |
| 1198 | func TestCmdDoWithEmptyString(t *testing.T) { |
| 1199 | setupFlowRoot(t) |
| 1200 | seedTask(t, "with-empty") |
| 1201 | spawns, _ := stubITerm(t) |
| 1202 | rc := cmdDo([]string{"with-empty", "--with", " "}) |
| 1203 | if rc != 2 { |
| 1204 | t.Errorf("rc=%d, want 2 for empty --with", rc) |
| 1205 | } |
| 1206 | if atomic.LoadInt64(spawns) != 0 { |
| 1207 | t.Errorf("empty --with should not spawn: %d", *spawns) |
| 1208 | } |
| 1209 | } |
| 1210 | |
| 1211 | func TestCmdDoWithFileMissing(t *testing.T) { |
| 1212 | setupFlowRoot(t) |
| 1213 | seedTask(t, "with-missing") |
| 1214 | spawns, _ := stubITerm(t) |
| 1215 | rc := cmdDo([]string{"with-missing", "--with-file", "/no/such/file/here.txt"}) |
| 1216 | if rc != 1 { |
| 1217 | t.Errorf("rc=%d, want 1 for missing file", rc) |
| 1218 | } |
| 1219 | if atomic.LoadInt64(spawns) != 0 { |
| 1220 | t.Errorf("missing --with-file should not spawn: %d", *spawns) |
| 1221 | } |
| 1222 | } |
| 1223 | |
| 1224 | func TestCmdDoWithReopensDoneTask(t *testing.T) { |
| 1225 | setupFlowRoot(t) |
| 1226 | seedTask(t, "with-done") |
| 1227 | |
| 1228 | db := openFlowDB(t) |
| 1229 | if _, err := db.Exec( |
| 1230 | `UPDATE tasks SET status='done', session_id='done-sid', session_started=?, updated_at=? WHERE slug='with-done'`, |
nothing calls this directly
no test coverage detected