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

Function captureStatsOutput

apps/cli/internal/cli/stats_test.go:78–93  ·  view source on GitHub ↗

captureStatsOutput runs the stats command and captures stdout.

(t *testing.T, args []string)

Source from the content-addressed store, hash-verified

76
77// captureStatsOutput runs the stats command and captures stdout.
78func captureStatsOutput(t *testing.T, args []string) (string, error) {
79 t.Helper()
80
81 oldStdout := os.Stdout
82 r, w, _ := os.Pipe()
83 os.Stdout = w
84
85 err := runStats(statsCmd, args)
86
87 w.Close()
88 os.Stdout = oldStdout
89
90 var buf bytes.Buffer
91 buf.ReadFrom(r)
92 return buf.String(), err
93}
94
95func TestRunStats_JSONOutput(t *testing.T) {
96 tmpDir := createStatsTestFiles(t)

Calls 1

runStatsFunction · 0.85

Tested by

no test coverage detected