MCPcopy Create free account
hub / github.com/driangle/taskmd / captureListTableOutput

Function captureListTableOutput

apps/cli/internal/cli/list_test.go:109–129  ·  view source on GitHub ↗

captureListTableOutput runs outputTable and captures stdout.

(t *testing.T, tasks []*model.Task, columns string)

Source from the content-addressed store, hash-verified

107
108// captureListTableOutput runs outputTable and captures stdout.
109func captureListTableOutput(t *testing.T, tasks []*model.Task, columns string) string {
110 t.Helper()
111
112 oldStdout := os.Stdout
113 r, w, _ := os.Pipe()
114 os.Stdout = w
115
116 err := outputTable(tasks, columns)
117 if err != nil {
118 w.Close()
119 os.Stdout = oldStdout
120 t.Fatalf("outputTable failed: %v", err)
121 }
122
123 w.Close()
124 os.Stdout = oldStdout
125
126 var buf bytes.Buffer
127 buf.ReadFrom(r)
128 return buf.String()
129}
130
131func TestListCommand_TableColorEnabled(t *testing.T) {
132 resetListFlags()

Calls 1

outputTableFunction · 0.85

Tested by

no test coverage detected