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

Function TestCmdDoneRunsSweepWhenSessionExists

internal/app/done_test.go:127–164  ·  view source on GitHub ↗

TestCmdDoneRunsSweepWhenSessionExists verifies that done invokes the claude runner exactly once with the task slug and a sweep prompt when the task has a session_id, and returns rc=0 on success.

(t *testing.T)

Source from the content-addressed store, hash-verified

125// claude runner exactly once with the task slug and a sweep prompt
126// when the task has a session_id, and returns rc=0 on success.
127func TestCmdDoneRunsSweepWhenSessionExists(t *testing.T) {
128 setupFlowRoot(t)
129 calls := stubClaudeRunner(t, nil)
130 if rc := cmdAdd([]string{"task", "Has Session"}); rc != 0 {
131 t.Fatalf("add rc=%d", rc)
132 }
133 // Manually populate session_id so the sweep gate fires.
134 db := openFlowDB(t)
135 if _, err := db.Exec(
136 `UPDATE tasks SET session_id=?, session_started=? WHERE slug=?`,
137 "deadbeef-uuid", flowdb.NowISO(), "has-session",
138 ); err != nil {
139 t.Fatalf("seed session_id: %v", err)
140 }
141 db.Close()
142
143 if rc := cmdDone([]string{"has-session"}); rc != 0 {
144 t.Fatalf("done rc=%d, want 0", rc)
145 }
146 if len(*calls) != 1 {
147 t.Fatalf("expected 1 sweep call, got %d", len(*calls))
148 }
149 got := (*calls)[0]
150 if !contains(got.prompt, "has-session") {
151 t.Errorf("call prompt missing task slug; got %q", got.prompt)
152 }
153 if got.prompt == "" {
154 t.Error("call prompt is empty")
155 }
156 // Sanity-check the prompt mentions key behavior so a regression in
157 // buildCloseoutSweepPrompt that drops the skill load or the
158 // transcript step gets caught here.
159 for _, want := range []string{"flow skill", "flow transcript has-session", "kb/"} {
160 if !contains(got.prompt, want) {
161 t.Errorf("prompt missing %q", want)
162 }
163 }
164}
165
166// TestCmdDoneCloseoutSweepIncludesProjectStep verifies that when the
167// task is attached to a project, the close-out prompt includes the

Callers

nothing calls this directly

Calls 8

NowISOFunction · 0.92
setupFlowRootFunction · 0.85
stubClaudeRunnerFunction · 0.85
cmdAddFunction · 0.85
openFlowDBFunction · 0.85
cmdDoneFunction · 0.85
ErrorMethod · 0.80
containsFunction · 0.70

Tested by

no test coverage detected