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

Function TestCmdDoHereRefusesWhenTranscriptMissing

internal/app/do_test.go:1190–1227  ·  view source on GitHub ↗

---------- 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)

Source from the content-addressed store, hash-verified

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
1198func 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
1211func 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
1224func 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'`,

Callers

nothing calls this directly

Calls 7

GetTaskFunction · 0.92
setupFlowRootFunction · 0.85
seedTaskAtCwdFunction · 0.85
stubClaudeStatMissingFunction · 0.85
captureStderrFunction · 0.85
cmdDoHereFunction · 0.85
openFlowDBFunction · 0.85

Tested by

no test coverage detected