--------------------------------------------------------------------------- classifyCheckState – fixture-based unit tests ---------------------------------------------------------------------------
(t *testing.T)
| 25 | // --------------------------------------------------------------------------- |
| 26 | |
| 27 | func TestClassifyCheckState(t *testing.T) { |
| 28 | tests := []struct { |
| 29 | name string |
| 30 | runs []PRCheckRun |
| 31 | statuses []PRCommitStatus |
| 32 | want CheckState |
| 33 | }{ |
| 34 | { |
| 35 | name: "empty check runs and statuses yields no_checks", |
| 36 | want: CheckStateNoChecks, |
| 37 | }, |
| 38 | { |
| 39 | name: "all successful check runs yields success", |
| 40 | runs: []PRCheckRun{ |
| 41 | {Name: "build", Status: "completed", Conclusion: "success"}, |
| 42 | {Name: "lint", Status: "completed", Conclusion: "success"}, |
| 43 | }, |
| 44 | want: CheckStateSuccess, |
| 45 | }, |
| 46 | { |
| 47 | name: "failed check run yields failed", |
| 48 | runs: []PRCheckRun{ |
| 49 | {Name: "build", Status: "completed", Conclusion: "success"}, |
| 50 | {Name: "test", Status: "completed", Conclusion: "failure"}, |
| 51 | }, |
| 52 | want: CheckStateFailed, |
| 53 | }, |
| 54 | { |
| 55 | name: "in progress check run yields pending", |
| 56 | runs: []PRCheckRun{ |
| 57 | {Name: "build", Status: "completed", Conclusion: "success"}, |
| 58 | {Name: "test", Status: "in_progress", Conclusion: ""}, |
| 59 | }, |
| 60 | want: CheckStatePending, |
| 61 | }, |
| 62 | { |
| 63 | name: "queued check run yields pending", |
| 64 | runs: []PRCheckRun{ |
| 65 | {Name: "build", Status: "queued", Conclusion: ""}, |
| 66 | }, |
| 67 | want: CheckStatePending, |
| 68 | }, |
| 69 | { |
| 70 | name: "branch protection rule failure yields policy_blocked", |
| 71 | runs: []PRCheckRun{ |
| 72 | {Name: "Branch protection rule check", Status: "completed", Conclusion: "failure"}, |
| 73 | }, |
| 74 | want: CheckStatePolicyBlocked, |
| 75 | }, |
| 76 | { |
| 77 | name: "action required on policy check yields policy_blocked", |
| 78 | runs: []PRCheckRun{ |
| 79 | {Name: "build", Status: "completed", Conclusion: "success"}, |
| 80 | {Name: "required status check", Status: "completed", Conclusion: "action_required"}, |
| 81 | }, |
| 82 | want: CheckStatePolicyBlocked, |
| 83 | }, |
| 84 | { |
nothing calls this directly
no test coverage detected