MCPcopy Create free account
hub / github.com/github/gh-aw / captureListOutput

Function captureListOutput

pkg/cli/list_workflows_command_test.go:128–144  ·  view source on GitHub ↗

captureListOutput calls RunListWorkflows and returns the captured stdout as a string.

(t *testing.T, dir, pattern string)

Source from the content-addressed store, hash-verified

126
127// captureListOutput calls RunListWorkflows and returns the captured stdout as a string.
128func captureListOutput(t *testing.T, dir, pattern string) string {
129 t.Helper()
130 oldStdout := os.Stdout
131 r, w, err := os.Pipe()
132 require.NoError(t, err, "Should create pipe")
133 os.Stdout = w
134
135 runErr := RunListWorkflows("", dir, pattern, false, true, "")
136
137 w.Close()
138 os.Stdout = oldStdout
139
140 var buf bytes.Buffer
141 _, _ = io.Copy(&buf, r)
142 require.NoError(t, runErr, "RunListWorkflows should not error")
143 return buf.String()
144}
145
146func TestRunListWorkflows_CompiledField(t *testing.T) {
147 tmpDir := t.TempDir()

Callers 1

Calls 3

RunListWorkflowsFunction · 0.85
CloseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected