(t *testing.T)
| 475 | } |
| 476 | |
| 477 | func TestPrintChecksJSON(t *testing.T) { |
| 478 | result := &ChecksResult{ |
| 479 | State: CheckStateSuccess, |
| 480 | RequiredState: CheckStateSuccess, |
| 481 | PRNumber: "10", |
| 482 | HeadSHA: "abc123", |
| 483 | CheckRuns: []PRCheckRun{ |
| 484 | {Name: "build", Status: "completed", Conclusion: "success", HTMLURL: "https://example.com/build"}, |
| 485 | }, |
| 486 | Statuses: []PRCommitStatus{ |
| 487 | {State: "success", Context: "ci/build"}, |
| 488 | }, |
| 489 | TotalCount: 2, |
| 490 | } |
| 491 | |
| 492 | stdout, stderr := captureOutput(t, func() error { |
| 493 | return printChecksJSON(result) |
| 494 | }) |
| 495 | assert.Empty(t, stderr, "printChecksJSON should not write to stderr") |
| 496 | |
| 497 | var got ChecksResult |
| 498 | require.NoError(t, json.Unmarshal([]byte(stdout), &got), "printChecksJSON output should be valid JSON") |
| 499 | assert.Equal(t, *result, got, "printChecksJSON should output the provided result data") |
| 500 | } |
| 501 | |
| 502 | func TestPrintChecksText(t *testing.T) { |
| 503 | tests := []struct { |
nothing calls this directly
no test coverage detected