captureListOutput calls RunListWorkflows and returns the captured stdout as a string.
(t *testing.T, dir, pattern string)
| 126 | |
| 127 | // captureListOutput calls RunListWorkflows and returns the captured stdout as a string. |
| 128 | func 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 | |
| 146 | func TestRunListWorkflows_CompiledField(t *testing.T) { |
| 147 | tmpDir := t.TempDir() |
no test coverage detected