(t *testing.T)
| 227 | } |
| 228 | |
| 229 | func TestFetchJobDetailsWithCountsIncludesSteps(t *testing.T) { |
| 230 | fakeBinDir := testutil.TempDir(t, "fake-gh-*") |
| 231 | fakeGH := filepath.Join(fakeBinDir, "gh") |
| 232 | argsLogPath := filepath.Join(fakeBinDir, "gh-args.log") |
| 233 | fakeGHScript := "#!/bin/sh\n" + |
| 234 | "printf '%s\\n' \"$*\" >> \"" + argsLogPath + "\"\n" + |
| 235 | "cat <<'EOF'\n" + |
| 236 | "{\"name\":\"agent\",\"status\":\"completed\",\"conclusion\":\"failure\",\"started_at\":\"2026-06-28T01:31:00Z\",\"completed_at\":\"2026-06-28T01:33:00Z\",\"steps\":[{\"name\":\"Set up job\",\"status\":\"completed\",\"conclusion\":\"success\"},{\"name\":\"Run agent\",\"status\":\"completed\",\"conclusion\":\"failure\"}]}\n" + |
| 237 | "EOF\n" |
| 238 | require.NoError(t, os.WriteFile(fakeGH, []byte(fakeGHScript), 0o755)) |
| 239 | |
| 240 | t.Setenv("PATH", fakeBinDir+string(os.PathListSeparator)+os.Getenv("PATH")) |
| 241 | |
| 242 | jobs, failedJobs, err := fetchJobDetailsWithCounts(28307653871, false) |
| 243 | require.NoError(t, err) |
| 244 | require.Len(t, jobs, 1) |
| 245 | assert.Equal(t, 1, failedJobs, "failed job count should include failed jobs") |
| 246 | assert.Equal(t, 2*time.Minute, jobs[0].Duration, "job duration should still be derived from timestamps") |
| 247 | require.Len(t, jobs[0].Steps, 2) |
| 248 | assert.Equal(t, "Run agent", jobs[0].Steps[1].Name, "step names should be parsed from gh api output") |
| 249 | assert.Equal(t, "failure", jobs[0].Steps[1].Conclusion, "step conclusions should be parsed from gh api output") |
| 250 | |
| 251 | argsLog, err := os.ReadFile(argsLogPath) |
| 252 | require.NoError(t, err) |
| 253 | assert.Contains(t, string(argsLog), "repos/{owner}/{repo}/actions/runs/28307653871/jobs", "should query the run jobs API") |
| 254 | assert.Contains(t, string(argsLog), "steps:", "gh jq projection should request step data") |
| 255 | } |
| 256 | |
| 257 | // TestFetchJobDetailsWithCountsNullConclusion verifies that jobs and steps with null conclusions |
| 258 | // (e.g. in-progress or queued jobs) are still parsed and not silently dropped. The jq projection |
nothing calls this directly
no test coverage detected