TestFetchJobDetailsWithCountsNullConclusion verifies that jobs and steps with null conclusions (e.g. in-progress or queued jobs) are still parsed and not silently dropped. The jq projection uses (.conclusion // "") to coerce null to empty string before JSON decoding.
(t *testing.T)
| 258 | // (e.g. in-progress or queued jobs) are still parsed and not silently dropped. The jq projection |
| 259 | // uses (.conclusion // "") to coerce null to empty string before JSON decoding. |
| 260 | func TestFetchJobDetailsWithCountsNullConclusion(t *testing.T) { |
| 261 | fakeBinDir := testutil.TempDir(t, "fake-gh-*") |
| 262 | fakeGH := filepath.Join(fakeBinDir, "gh") |
| 263 | // Simulate jq coercing null -> "" before output (as (.conclusion // "") does). |
| 264 | // A job still in progress has conclusion="" for itself and for any pending steps. |
| 265 | fakeGHScript := "#!/bin/sh\n" + |
| 266 | "cat <<'EOF'\n" + |
| 267 | "{\"name\":\"agent\",\"status\":\"in_progress\",\"conclusion\":\"\",\"started_at\":\"2026-06-28T01:31:00Z\",\"completed_at\":\"0001-01-01T00:00:00Z\",\"steps\":[{\"name\":\"Set up job\",\"status\":\"completed\",\"conclusion\":\"success\"},{\"name\":\"Run agent\",\"status\":\"in_progress\",\"conclusion\":\"\"}]}\n" + |
| 268 | "EOF\n" |
| 269 | require.NoError(t, os.WriteFile(fakeGH, []byte(fakeGHScript), 0o755)) |
| 270 | |
| 271 | t.Setenv("PATH", fakeBinDir+string(os.PathListSeparator)+os.Getenv("PATH")) |
| 272 | |
| 273 | jobs, failedJobs, err := fetchJobDetailsWithCounts(28307653871, false) |
| 274 | require.NoError(t, err) |
| 275 | require.Len(t, jobs, 1, "in-progress jobs with null conclusion should not be dropped") |
| 276 | assert.Equal(t, 0, failedJobs, "in-progress job should not count as failed") |
| 277 | assert.Equal(t, "in_progress", jobs[0].Status) |
| 278 | assert.Empty(t, jobs[0].Conclusion, "null conclusion should be coerced to empty string") |
| 279 | require.Len(t, jobs[0].Steps, 2) |
| 280 | assert.Empty(t, jobs[0].Steps[1].Conclusion, "null step conclusion should be coerced to empty string") |
| 281 | } |
| 282 | |
| 283 | func TestWorkflowRunsSpinnerMessage(t *testing.T) { |
| 284 | tests := []struct { |
nothing calls this directly
no test coverage detected