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

Function TestCmdListProjectsFormatJSON

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

Source from the content-addressed store, hash-verified

1011}
1012
1013func TestCmdListProjectsFormatJSON(t *testing.T) {
1014 root, db := showListEditDB(t)
1015 insertProject(t, db, "p1", "P1", filepath.Join(root, "x"), "high")
1016 insertTask(t, db, "p1-ip", "I", "in-progress", "high", filepath.Join(root, "x"), "p1")
1017 insertTask(t, db, "p1-bl", "B", "backlog", "medium", filepath.Join(root, "x"), "p1")
1018
1019 out := captureStdout(t, func() {
1020 if rc := cmdList([]string{"projects", "--format", "json"}); rc != 0 {
1021 t.Fatalf("rc=%d", rc)
1022 }
1023 })
1024 var rows []map[string]any
1025 if err := json.Unmarshal([]byte(out), &rows); err != nil {
1026 t.Fatalf("invalid JSON: %v\nout=%q", err, out)
1027 }
1028 if len(rows) != 1 {
1029 t.Fatalf("want 1 project, got %d", len(rows))
1030 }
1031 r := rows[0]
1032 if r["slug"] != "p1" {
1033 t.Errorf("slug = %v, want p1", r["slug"])
1034 }
1035 if r["in_progress"].(float64) != 1 || r["backlog"].(float64) != 1 {
1036 t.Errorf("breakdown wrong: %+v", r)
1037 }
1038 // `name` is included in JSON so the workspace layer gets legible titles.
1039 if r["name"] != "P1" {
1040 t.Errorf("name = %v, want P1", r["name"])
1041 }
1042}

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