TestCodeReview tests the code review checker.
(t *testing.T)
| 30 | |
| 31 | // TestCodeReview tests the code review checker. |
| 32 | func TestCodereview(t *testing.T) { |
| 33 | t.Parallel() |
| 34 | tests := []struct { |
| 35 | name string |
| 36 | commitErr error |
| 37 | commits []clients.Commit |
| 38 | expected scut.TestReturn |
| 39 | }{ |
| 40 | { |
| 41 | name: "no commits", |
| 42 | expected: scut.TestReturn{ |
| 43 | Score: -1, |
| 44 | }, |
| 45 | }, |
| 46 | { |
| 47 | name: "no commits due to error", |
| 48 | commitErr: errors.New("error fetching commits"), |
| 49 | expected: scut.TestReturn{ |
| 50 | Score: -1, |
| 51 | Error: sce.ErrScorecardInternal, |
| 52 | }, |
| 53 | }, |
| 54 | { |
| 55 | name: "Valid GitHub PR", |
| 56 | commits: []clients.Commit{ |
| 57 | { |
| 58 | SHA: "sha", |
| 59 | Committer: clients.User{ |
| 60 | Login: "bob", |
| 61 | }, |
| 62 | AssociatedMergeRequest: clients.PullRequest{ |
| 63 | Number: 1, |
| 64 | MergedAt: time.Now(), |
| 65 | Reviews: []clients.Review{ |
| 66 | { |
| 67 | Author: &clients.User{Login: "alice"}, |
| 68 | State: "APPROVED", |
| 69 | }, |
| 70 | }, |
| 71 | }, |
| 72 | }, |
| 73 | }, |
| 74 | expected: scut.TestReturn{ |
| 75 | Score: 10, |
| 76 | }, |
| 77 | }, |
| 78 | { |
| 79 | name: "Valid Prow PR as not a bot", |
| 80 | commits: []clients.Commit{ |
| 81 | { |
| 82 | SHA: "sha", |
| 83 | Committer: clients.User{ |
| 84 | Login: "user", |
| 85 | }, |
| 86 | AssociatedMergeRequest: clients.PullRequest{ |
| 87 | Number: 1, |
| 88 | MergedAt: time.Now(), |
| 89 | Labels: []clients.Label{ |
nothing calls this directly
no test coverage detected