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

Function captureStdout

apps/cli/internal/web/server_test.go:210–229  ·  view source on GitHub ↗
(t *testing.T, fn func())

Source from the content-addressed store, hash-verified

208}
209
210func captureStdout(t *testing.T, fn func()) string {
211 t.Helper()
212 r, w, err := os.Pipe()
213 if err != nil {
214 t.Fatalf("failed to create pipe: %v", err)
215 }
216 old := os.Stdout
217 os.Stdout = w
218
219 fn()
220
221 w.Close()
222 os.Stdout = old
223
224 data, err2 := io.ReadAll(r)
225 if err2 != nil {
226 t.Fatalf("failed to read pipe: %v", err2)
227 }
228 return string(data)
229}
230
231func TestPrintBanner_Default(t *testing.T) {
232 dir := createTestTaskDir(t)

Callers 2

TestPrintBanner_DefaultFunction · 0.85

Calls 1

ReadAllMethod · 0.80

Tested by

no test coverage detected