(t *testing.T)
| 880 | } |
| 881 | |
| 882 | func TestCmdListTasksFormatTSV(t *testing.T) { |
| 883 | root, db := showListEditDB(t) |
| 884 | insertTask(t, db, "only-one", "Only", "in-progress", "high", filepath.Join(root, "x"), nil) |
| 885 | if _, err := db.Exec(`UPDATE tasks SET waiting_on = ? WHERE slug = ?`, "Alice", "only-one"); err != nil { |
| 886 | t.Fatal(err) |
| 887 | } |
| 888 | |
| 889 | out := captureStdout(t, func() { |
| 890 | if rc := cmdList([]string{"tasks", "--format", "tsv"}); rc != 0 { |
| 891 | t.Fatalf("rc=%d", rc) |
| 892 | } |
| 893 | }) |
| 894 | lines := strings.Split(strings.TrimRight(out, "\n"), "\n") |
| 895 | if len(lines) != 2 { |
| 896 | t.Fatalf("want 2 lines (header + 1 row), got %d:\n%s", len(lines), out) |
| 897 | } |
| 898 | header := strings.Split(lines[0], "\t") |
| 899 | row := strings.Split(lines[1], "\t") |
| 900 | if len(header) != len(row) { |
| 901 | t.Errorf("column count mismatch: header=%d, row=%d", len(header), len(row)) |
| 902 | } |
| 903 | // `waiting_on` must be a first-class column (raw value, no [waiting: ...] |
| 904 | // prefix and no ellipsis truncation) so scripts can pipe it cleanly. |
| 905 | waitIdx := -1 |
| 906 | for i, h := range header { |
| 907 | if h == "waiting_on" { |
| 908 | waitIdx = i |
| 909 | break |
| 910 | } |
| 911 | } |
| 912 | if waitIdx < 0 { |
| 913 | t.Fatalf("waiting_on header missing: %v", header) |
| 914 | } |
| 915 | if row[waitIdx] != "Alice" { |
| 916 | t.Errorf("waiting_on cell = %q, want %q", row[waitIdx], "Alice") |
| 917 | } |
| 918 | } |
| 919 | |
| 920 | func TestCmdListTasksFormatBad(t *testing.T) { |
| 921 | _, _ = showListEditDB(t) |
nothing calls this directly
no test coverage detected