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

Function TestCmdListTasksFormatJSON

internal/app/list_test.go:754–790  ·  view source on GitHub ↗

---------- --format / --no-color / --no-truncate ----------

(t *testing.T)

Source from the content-addressed store, hash-verified

752// ---------- --format / --no-color / --no-truncate ----------
753
754func TestCmdListTasksFormatJSON(t *testing.T) {
755 root, db := showListEditDB(t)
756 insertProject(t, db, "demo", "Demo", filepath.Join(root, "repo"), "high")
757 insertTask(t, db, "a-ip", "Alpha IP", "in-progress", "high", filepath.Join(root, "repo"), "demo")
758 insertTask(t, db, "b-bl", "Beta BL", "backlog", "medium", filepath.Join(root, "repo"), nil)
759
760 out := captureStdout(t, func() {
761 if rc := cmdList([]string{"tasks", "--format", "json"}); rc != 0 {
762 t.Fatalf("rc=%d", rc)
763 }
764 })
765 var rows []taskListRow
766 if err := json.Unmarshal([]byte(out), &rows); err != nil {
767 t.Fatalf("output is not valid JSON: %v\nout=%q", err, out)
768 }
769 if len(rows) != 2 {
770 t.Fatalf("got %d rows, want 2: %+v", len(rows), rows)
771 }
772 // Expect priority sort: high before medium.
773 if rows[0].Slug != "a-ip" || rows[0].Priority != "high" || rows[0].Status != "in-progress" {
774 t.Errorf("row 0 unexpected: %+v", rows[0])
775 }
776 if rows[1].Slug != "b-bl" || rows[1].Priority != "medium" || rows[1].Status != "backlog" {
777 t.Errorf("row 1 unexpected: %+v", rows[1])
778 }
779 if rows[0].Project != "demo" {
780 t.Errorf("row 0 should carry project=demo, got %q", rows[0].Project)
781 }
782 // Floating task must not carry a project value.
783 if rows[1].Project != "" {
784 t.Errorf("row 1 should be floating, got project=%q", rows[1].Project)
785 }
786 // Names are carried in JSON so consumers get legible titles, not slugs.
787 if rows[0].Name != "Alpha IP" || rows[1].Name != "Beta BL" {
788 t.Errorf("names = %q,%q, want \"Alpha IP\",\"Beta BL\"", rows[0].Name, rows[1].Name)
789 }
790}
791
792func TestCmdListTasksFormatJSONDueRaw(t *testing.T) {
793 root, db := showListEditDB(t)

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected