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

Function TestPrintChecksJSON

pkg/cli/checks_command_test.go:477–500  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

475}
476
477func 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
502func TestPrintChecksText(t *testing.T) {
503 tests := []struct {

Callers

nothing calls this directly

Calls 2

captureOutputFunction · 0.85
printChecksJSONFunction · 0.85

Tested by

no test coverage detected