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

Function TestViewWorkflowRun_WithOwnerRepo_ShowsRunURL

pkg/cli/view_command_test.go:185–222  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

183}
184
185func TestViewWorkflowRun_WithOwnerRepo_ShowsRunURL(t *testing.T) {
186 logsDir := buildViewRunDir(t)
187
188 opts := ViewOptions{
189 Owner: "myorg",
190 Repo: "myrepo",
191 Hostname: "github.com",
192 OutputDir: logsDir,
193 Verbose: false,
194 }
195
196 origStdout := os.Stdout
197 r, w, err := os.Pipe()
198 if err != nil {
199 t.Fatalf("os.Pipe: %v", err)
200 }
201 os.Stdout = w
202
203 runErr := ViewWorkflowRun(context.Background(), 9999, opts)
204
205 w.Close()
206 os.Stdout = origStdout
207 outBytes, readErr := io.ReadAll(r)
208 if readErr != nil {
209 t.Fatalf("reading captured output: %v", readErr)
210 }
211 output := string(outBytes)
212
213 if runErr != nil {
214 t.Errorf("ViewWorkflowRun returned unexpected error: %v", runErr)
215 }
216
217 // The run URL should appear at the end of the output.
218 wantURL := "https://github.com/myorg/myrepo/actions/runs/9999"
219 if !strings.Contains(output, wantURL) {
220 t.Errorf("output missing run URL %q; got:\n%s", wantURL, output)
221 }
222}
223
224func TestViewWorkflowRun_WithSafeOutputs_ShowsSection(t *testing.T) {
225 logsDir := buildViewRunDir(t)

Callers

nothing calls this directly

Calls 5

buildViewRunDirFunction · 0.85
ViewWorkflowRunFunction · 0.85
BackgroundMethod · 0.80
CloseMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected