captureListTableOutput runs outputTable and captures stdout.
(t *testing.T, tasks []*model.Task, columns string)
| 107 | |
| 108 | // captureListTableOutput runs outputTable and captures stdout. |
| 109 | func 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 | |
| 131 | func TestListCommand_TableColorEnabled(t *testing.T) { |
| 132 | resetListFlags() |
no test coverage detected