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

Function TestCmdListTasksFormatTSV

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

Source from the content-addressed store, hash-verified

880}
881
882func 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
920func TestCmdListTasksFormatBad(t *testing.T) {
921 _, _ = showListEditDB(t)

Callers

nothing calls this directly

Calls 4

showListEditDBFunction · 0.85
captureStdoutFunction · 0.85
cmdListFunction · 0.85
insertTaskFunction · 0.70

Tested by

no test coverage detected