| 26 | ) |
| 27 | |
| 28 | func Test_Run(t *testing.T) { |
| 29 | t.Parallel() |
| 30 | trueVal := true |
| 31 | falseVal := false |
| 32 | branchVal1 := "branch-name1" |
| 33 | branchVal2 := "branch-name1" |
| 34 | //nolint:govet |
| 35 | tests := []struct { |
| 36 | name string |
| 37 | raw *checker.RawResults |
| 38 | outcomes []finding.Outcome |
| 39 | err error |
| 40 | }{ |
| 41 | { |
| 42 | name: "1 branch requires PRs to change code", |
| 43 | raw: &checker.RawResults{ |
| 44 | BranchProtectionResults: checker.BranchProtectionsData{ |
| 45 | Branches: []clients.BranchRef{ |
| 46 | { |
| 47 | Name: &branchVal1, |
| 48 | BranchProtectionRule: clients.BranchProtectionRule{ |
| 49 | PullRequestRule: clients.PullRequestRule{ |
| 50 | Required: &trueVal, |
| 51 | }, |
| 52 | }, |
| 53 | }, |
| 54 | }, |
| 55 | }, |
| 56 | }, |
| 57 | outcomes: []finding.Outcome{ |
| 58 | finding.OutcomeTrue, |
| 59 | }, |
| 60 | }, |
| 61 | { |
| 62 | name: "2 branches require PRs to change code = 2 true outcomes", |
| 63 | raw: &checker.RawResults{ |
| 64 | BranchProtectionResults: checker.BranchProtectionsData{ |
| 65 | Branches: []clients.BranchRef{ |
| 66 | { |
| 67 | Name: &branchVal1, |
| 68 | BranchProtectionRule: clients.BranchProtectionRule{ |
| 69 | PullRequestRule: clients.PullRequestRule{ |
| 70 | Required: &trueVal, |
| 71 | }, |
| 72 | }, |
| 73 | }, |
| 74 | { |
| 75 | Name: &branchVal2, |
| 76 | BranchProtectionRule: clients.BranchProtectionRule{ |
| 77 | PullRequestRule: clients.PullRequestRule{ |
| 78 | Required: &trueVal, |
| 79 | }, |
| 80 | }, |
| 81 | }, |
| 82 | }, |
| 83 | }, |
| 84 | }, |
| 85 | outcomes: []finding.Outcome{ |