(t *testing.T)
| 530 | } |
| 531 | |
| 532 | func TestComputeRequiredCheckStatus(t *testing.T) { |
| 533 | strPtr := func(s string) *string { return &s } |
| 534 | |
| 535 | tests := []struct { |
| 536 | name string |
| 537 | contexts []checkContextNode |
| 538 | requiredChecks map[string]bool |
| 539 | expect github.CheckStatus |
| 540 | }{ |
| 541 | // === Basic cases === |
| 542 | { |
| 543 | name: "NoContexts_NoRequired", |
| 544 | contexts: []checkContextNode{}, |
| 545 | requiredChecks: map[string]bool{"ci": true}, |
| 546 | expect: github.CheckStatusPending, // required check hasn't reported yet |
| 547 | }, |
| 548 | { |
| 549 | name: "NoContexts_EmptyRequired", |
| 550 | contexts: []checkContextNode{}, |
| 551 | requiredChecks: map[string]bool{}, |
| 552 | expect: github.CheckStatusPass, |
| 553 | }, |
| 554 | |
| 555 | // === CheckRun states === |
| 556 | { |
| 557 | name: "CheckRun_RequiredPasses", |
| 558 | contexts: []checkContextNode{ |
| 559 | {TypeName: "CheckRun", Name: "ci", Status: "COMPLETED", Conclusion: strPtr("SUCCESS")}, |
| 560 | }, |
| 561 | requiredChecks: map[string]bool{"ci": true}, |
| 562 | expect: github.CheckStatusPass, |
| 563 | }, |
| 564 | { |
| 565 | name: "CheckRun_RequiredFails", |
| 566 | contexts: []checkContextNode{ |
| 567 | {TypeName: "CheckRun", Name: "ci", Status: "COMPLETED", Conclusion: strPtr("FAILURE")}, |
| 568 | }, |
| 569 | requiredChecks: map[string]bool{"ci": true}, |
| 570 | expect: github.CheckStatusFail, |
| 571 | }, |
| 572 | { |
| 573 | name: "CheckRun_RequiredPending", |
| 574 | contexts: []checkContextNode{ |
| 575 | {TypeName: "CheckRun", Name: "ci", Status: "IN_PROGRESS"}, |
| 576 | }, |
| 577 | requiredChecks: map[string]bool{"ci": true}, |
| 578 | expect: github.CheckStatusPending, |
| 579 | }, |
| 580 | { |
| 581 | name: "CheckRun_RequiredQueued", |
| 582 | contexts: []checkContextNode{ |
| 583 | {TypeName: "CheckRun", Name: "ci", Status: "QUEUED"}, |
| 584 | }, |
| 585 | requiredChecks: map[string]bool{"ci": true}, |
| 586 | expect: github.CheckStatusPending, |
| 587 | }, |
| 588 | { |
| 589 | name: "CheckRun_NeutralPasses", |
nothing calls this directly
no test coverage detected