(t *testing.T)
| 183 | } |
| 184 | |
| 185 | func 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 | |
| 224 | func TestViewWorkflowRun_WithSafeOutputs_ShowsSection(t *testing.T) { |
| 225 | logsDir := buildViewRunDir(t) |
nothing calls this directly
no test coverage detected