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

Function TestCmdRunPlaybookCreatesRunTask

internal/app/run_test.go:94–144  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

92}
93
94func TestCmdRunPlaybookCreatesRunTask(t *testing.T) {
95 setupFlowRoot(t)
96 wd := t.TempDir()
97 if rc := cmdAdd([]string{"playbook", "Triage", "--slug", "tri", "--work-dir", wd}); rc != 0 {
98 t.Fatal()
99 }
100
101 _, lastScript := stubITerm(t)
102
103 if rc := cmdRun([]string{"playbook", "tri"}); rc != 0 {
104 t.Fatalf("rc=%d", rc)
105 }
106
107 db := openFlowDB(t)
108 rows, err := db.Query(`SELECT slug FROM tasks WHERE kind='playbook_run' AND playbook_slug='tri'`)
109 if err != nil {
110 t.Fatal(err)
111 }
112 defer rows.Close()
113 var runSlug string
114 count := 0
115 for rows.Next() {
116 count++
117 if err := rows.Scan(&runSlug); err != nil {
118 t.Fatal(err)
119 }
120 }
121 if count != 1 {
122 t.Fatalf("expected 1 run task, got %d", count)
123 }
124 if !strings.HasPrefix(runSlug, "tri--") {
125 t.Errorf("expected slug prefix 'tri--', got %q", runSlug)
126 }
127
128 // brief.md should be a copy of playbook brief.md.
129 root, _ := flowRoot()
130 pbBrief, _ := os.ReadFile(filepath.Join(root, "playbooks", "tri", "brief.md"))
131 runBrief, err := os.ReadFile(filepath.Join(root, "tasks", runSlug, "brief.md"))
132 if err != nil {
133 t.Errorf("run brief.md missing: %v", err)
134 }
135 if string(pbBrief) != string(runBrief) {
136 t.Errorf("run brief should be verbatim copy of playbook brief")
137 }
138
139 // iTerm should have been called with a 'claude' command.
140 script := lastScript()
141 if !strings.Contains(script, "claude --session-id ") {
142 t.Errorf("expected claude session-id in spawn script, got: %q", script)
143 }
144}
145
146// TestCmdRunPlaybookAutoForwards: `flow run playbook <slug> --auto`
147// creates the run task and launches it headlessly via the detached

Callers

nothing calls this directly

Calls 6

setupFlowRootFunction · 0.85
cmdAddFunction · 0.85
stubITermFunction · 0.85
cmdRunFunction · 0.85
openFlowDBFunction · 0.85
flowRootFunction · 0.85

Tested by

no test coverage detected