(t *testing.T)
| 500 | } |
| 501 | |
| 502 | func TestPrintChecksText(t *testing.T) { |
| 503 | tests := []struct { |
| 504 | name string |
| 505 | state CheckState |
| 506 | expectedStdout string |
| 507 | expectedStderrParts []string |
| 508 | }{ |
| 509 | { |
| 510 | name: "success", |
| 511 | state: CheckStateSuccess, |
| 512 | expectedStdout: "success\n", |
| 513 | expectedStderrParts: []string{ |
| 514 | "PR #10: all checks passed (3 total)", |
| 515 | }, |
| 516 | }, |
| 517 | { |
| 518 | name: "failed", |
| 519 | state: CheckStateFailed, |
| 520 | expectedStdout: "failed\n", |
| 521 | expectedStderrParts: []string{ |
| 522 | "PR #10: checks failed (3 total)", |
| 523 | }, |
| 524 | }, |
| 525 | { |
| 526 | name: "pending", |
| 527 | state: CheckStatePending, |
| 528 | expectedStdout: "pending\n", |
| 529 | expectedStderrParts: []string{ |
| 530 | "PR #10: checks pending (3 total)", |
| 531 | }, |
| 532 | }, |
| 533 | { |
| 534 | name: "no checks", |
| 535 | state: CheckStateNoChecks, |
| 536 | expectedStdout: "no_checks\n", |
| 537 | expectedStderrParts: []string{ |
| 538 | "PR #10: no checks configured or triggered", |
| 539 | }, |
| 540 | }, |
| 541 | { |
| 542 | name: "policy blocked", |
| 543 | state: CheckStatePolicyBlocked, |
| 544 | expectedStdout: "policy_blocked\n", |
| 545 | expectedStderrParts: []string{ |
| 546 | "PR #10: blocked by policy or account gate (3 total)", |
| 547 | }, |
| 548 | }, |
| 549 | } |
| 550 | |
| 551 | for _, tt := range tests { |
| 552 | t.Run(tt.name, func(t *testing.T) { |
| 553 | result := &ChecksResult{State: tt.state, PRNumber: "10", TotalCount: 3} |
| 554 | stdout, stderr := captureOutput(t, func() error { |
| 555 | return printChecksText(result) |
| 556 | }) |
| 557 | |
| 558 | assert.Equal(t, tt.expectedStdout, stdout, "printChecksText should write normalized state to stdout") |
| 559 | for _, part := range tt.expectedStderrParts { |
nothing calls this directly
no test coverage detected