TestCmdDoneRefusesTaskWithoutSession pins the session-id invariant at the friendly-error layer for `flow done`: a backlog task with no session_id has no transcript to sweep, so done refuses with a pointer to `flow archive`. Replaces the older "skips sweep when no session" test — that path is no long
(t *testing.T)
| 103 | // "skips sweep when no session" test — that path is no longer |
| 104 | // reachable under the invariant. |
| 105 | func TestCmdDoneRefusesTaskWithoutSession(t *testing.T) { |
| 106 | setupFlowRoot(t) |
| 107 | calls := stubClaudeRunner(t, errors.New("should not be called")) |
| 108 | if rc := cmdAdd([]string{"task", "No Session Task"}); rc != 0 { |
| 109 | t.Fatalf("add rc=%d", rc) |
| 110 | } |
| 111 | if rc := cmdDone([]string{"no-session-task"}); rc != 1 { |
| 112 | t.Errorf("done rc=%d, want 1 (sessionless task should be refused)", rc) |
| 113 | } |
| 114 | if len(*calls) != 0 { |
| 115 | t.Errorf("expected 0 sweep calls, got %d", len(*calls)) |
| 116 | } |
| 117 | db := openFlowDB(t) |
| 118 | task, _ := flowdb.GetTask(db, "no-session-task") |
| 119 | if task.Status != "backlog" { |
| 120 | t.Errorf("status = %q, want backlog (refused done should not flip)", task.Status) |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | // TestCmdDoneRunsSweepWhenSessionExists verifies that done invokes the |
| 125 | // claude runner exactly once with the task slug and a sweep prompt |
nothing calls this directly
no test coverage detected