TestCmdListTasksAutoColumn: `flow list tasks` has a dedicated, always-on AUTO column. A running run shows "running "; terminal runs show the status word. The AUTO marker no longer lives in NOTES. TSV exposes auto_run + auto_run_pid as first-class columns.
(t *testing.T)
| 814 | // status word. The AUTO marker no longer lives in NOTES. TSV exposes |
| 815 | // auto_run + auto_run_pid as first-class columns. |
| 816 | func TestCmdListTasksAutoColumn(t *testing.T) { |
| 817 | root, db := showListEditDB(t) |
| 818 | insertTask(t, db, "run-task", "Running", "in-progress", "high", filepath.Join(root, "x"), nil) |
| 819 | insertTask(t, db, "dead-task", "Dead", "in-progress", "high", filepath.Join(root, "y"), nil) |
| 820 | if _, err := db.Exec(`UPDATE tasks SET auto_run_status='running', auto_run_pid=18148 WHERE slug='run-task'`); err != nil { |
| 821 | t.Fatal(err) |
| 822 | } |
| 823 | if _, err := db.Exec(`UPDATE tasks SET auto_run_status='dead', auto_run_finished=? WHERE slug='dead-task'`, flowdb.NowISO()); err != nil { |
| 824 | t.Fatal(err) |
| 825 | } |
| 826 | |
| 827 | // Keep the running pid "alive" so reconcile doesn't flip it to dead. |
| 828 | oldAlive := processAlive |
| 829 | processAlive = func(pid int) bool { return true } |
| 830 | t.Cleanup(func() { processAlive = oldAlive }) |
| 831 | |
| 832 | out := captureStdout(t, func() { |
| 833 | if rc := cmdList([]string{"tasks", "--no-color"}); rc != 0 { |
| 834 | t.Fatalf("rc=%d", rc) |
| 835 | } |
| 836 | }) |
| 837 | if !strings.Contains(out, "AUTO") { |
| 838 | t.Errorf("table should have an AUTO column header; out=%q", out) |
| 839 | } |
| 840 | if !strings.Contains(out, "running 18148") { |
| 841 | t.Errorf("running task should show 'running <pid>' in AUTO column; out=%q", out) |
| 842 | } |
| 843 | if !strings.Contains(out, "dead") { |
| 844 | t.Errorf("dead task should show 'dead' in AUTO column; out=%q", out) |
| 845 | } |
| 846 | if strings.Contains(out, "[auto:") { |
| 847 | t.Errorf("AUTO marker should no longer appear in NOTES; out=%q", out) |
| 848 | } |
| 849 | |
| 850 | // TSV exposes auto_run + auto_run_pid as first-class columns. |
| 851 | tsv := captureStdout(t, func() { |
| 852 | if rc := cmdList([]string{"tasks", "--format", "tsv"}); rc != 0 { |
| 853 | t.Fatalf("rc=%d", rc) |
| 854 | } |
| 855 | }) |
| 856 | lines := strings.Split(strings.TrimRight(tsv, "\n"), "\n") |
| 857 | header := strings.Split(lines[0], "\t") |
| 858 | col := func(name string) int { |
| 859 | for i, h := range header { |
| 860 | if h == name { |
| 861 | return i |
| 862 | } |
| 863 | } |
| 864 | return -1 |
| 865 | } |
| 866 | if col("auto_run") < 0 || col("auto_run_pid") < 0 { |
| 867 | t.Fatalf("auto_run/auto_run_pid headers missing: %v", header) |
| 868 | } |
| 869 | for _, ln := range lines[1:] { |
| 870 | row := strings.Split(ln, "\t") |
| 871 | if row[col("slug")] == "run-task" { |
| 872 | if row[col("auto_run")] != "running" { |
| 873 | t.Errorf("run-task auto_run = %q, want running", row[col("auto_run")]) |
nothing calls this directly
no test coverage detected