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

Function TestCmdListRuns

internal/app/list_test.go:508–558  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

506}
507
508func TestCmdListRuns(t *testing.T) {
509 setupFlowRoot(t)
510 db := openFlowDB(t)
511 wd := t.TempDir()
512 if err := flowdb.UpsertPlaybook(db, &flowdb.Playbook{Slug: "p1", Name: "P1", WorkDir: wd}); err != nil {
513 t.Fatal(err)
514 }
515 if err := flowdb.UpsertPlaybook(db, &flowdb.Playbook{Slug: "p2", Name: "P2", WorkDir: wd}); err != nil {
516 t.Fatal(err)
517 }
518 now := flowdb.NowISO()
519 for _, slug := range []string{"p1--2026-04-30-10-30", "p1--2026-04-30-11-00"} {
520 if _, err := db.Exec(
521 `INSERT INTO tasks (slug, name, status, kind, playbook_slug, priority, work_dir, session_id, created_at, updated_at)
522 VALUES (?, ?, 'in-progress', 'playbook_run', 'p1', 'medium', ?, ?, ?, ?)`,
523 slug, slug, wd, fakeSessionID(slug), now, now,
524 ); err != nil {
525 t.Fatal(err)
526 }
527 }
528 if _, err := db.Exec(
529 `INSERT INTO tasks (slug, name, status, kind, playbook_slug, priority, work_dir, session_id, created_at, updated_at)
530 VALUES ('p2--2026-04-30-10-30', 'p2-r', 'done', 'playbook_run', 'p2', 'medium', ?, ?, ?, ?)`,
531 wd, fakeSessionID("p2--2026-04-30-10-30"), now, now,
532 ); err != nil {
533 t.Fatal(err)
534 }
535
536 // All runs
537 out := captureShowStdout(t, func() {
538 if rc := cmdList([]string{"runs"}); rc != 0 {
539 t.Fatal()
540 }
541 })
542 if !strings.Contains(out, "p1--") || !strings.Contains(out, "p2--") {
543 t.Errorf("expected all runs:\n%s", out)
544 }
545
546 // Filtered by playbook
547 out = captureShowStdout(t, func() {
548 if rc := cmdList([]string{"runs", "p1"}); rc != 0 {
549 t.Fatal()
550 }
551 })
552 if !strings.Contains(out, "p1--") {
553 t.Errorf("expected p1 runs:\n%s", out)
554 }
555 if strings.Contains(out, "p2--") {
556 t.Errorf("p2 runs should be filtered out:\n%s", out)
557 }
558}
559
560func TestCmdListRunsByStatus(t *testing.T) {
561 setupFlowRoot(t)

Callers

nothing calls this directly

Calls 7

UpsertPlaybookFunction · 0.92
NowISOFunction · 0.92
setupFlowRootFunction · 0.85
openFlowDBFunction · 0.85
fakeSessionIDFunction · 0.85
captureShowStdoutFunction · 0.85
cmdListFunction · 0.85

Tested by

no test coverage detected