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

Function TestBGAgentStatus

internal/app/background_test.go:296–326  ·  view source on GitHub ↗

TestBGAgentStatus: a claude-bound task whose session is in the registry resolves to its live agent (status/state/pid); absent or session-less tasks resolve to nil.

(t *testing.T)

Source from the content-addressed store, hash-verified

294// resolves to its live agent (status/state/pid); absent or session-less
295// tasks resolve to nil.
296func TestBGAgentStatus(t *testing.T) {
297 stubBGMode(t)
298 reg := bgAgentsJSON(bgFullSID)
299 stubBGCommand(t, &reg)
300
301 live := &flowdb.Task{
302 Slug: "x",
303 Harness: sql.NullString{String: "claude", Valid: true},
304 SessionID: sql.NullString{String: bgFullSID, Valid: true},
305 }
306 a := bgAgentStatus(live)
307 if a == nil {
308 t.Fatal("bgAgentStatus = nil, want the live agent")
309 }
310 if a.Status != "busy" || a.State != "working" || a.PID == 0 {
311 t.Errorf("agent fields = %+v, want busy/working with a pid", *a)
312 }
313
314 absent := &flowdb.Task{
315 Harness: sql.NullString{String: "claude", Valid: true},
316 SessionID: sql.NullString{String: "ffffffff-0000-4000-8000-000000000000", Valid: true},
317 }
318 if bgAgentStatus(absent) != nil {
319 t.Error("bgAgentStatus for absent session = non-nil, want nil")
320 }
321
322 noSession := &flowdb.Task{Harness: sql.NullString{String: "claude", Valid: true}}
323 if bgAgentStatus(noSession) != nil {
324 t.Error("bgAgentStatus for session-less task = non-nil, want nil")
325 }
326}
327
328// TestLiveSessionsIncludesBackgroundAgents: the [live] detection used by
329// `flow list` must count background agents (which don't show in the ps

Callers

nothing calls this directly

Calls 5

stubBGModeFunction · 0.85
bgAgentsJSONFunction · 0.85
stubBGCommandFunction · 0.85
bgAgentStatusFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected