(t *testing.T)
| 99 | } |
| 100 | |
| 101 | func TestStatusString(t *testing.T) { |
| 102 | type testcase struct { |
| 103 | pr *PullRequest |
| 104 | cfg *config.Config |
| 105 | expect string |
| 106 | } |
| 107 | |
| 108 | cfg := func(requireChecks bool, requireApproval bool) *config.Config { |
| 109 | return &config.Config{ |
| 110 | Repo: &config.RepoConfig{ |
| 111 | RequireChecks: requireChecks, |
| 112 | RequireApproval: requireApproval, |
| 113 | }, |
| 114 | User: &config.UserConfig{ |
| 115 | StatusBitsEmojis: false, |
| 116 | }, |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | pr := func(checks CheckStatus, approved bool, noConflics bool, stacked bool) *PullRequest { |
| 121 | return &PullRequest{ |
| 122 | MergeStatus: PullRequestMergeStatus{ |
| 123 | ChecksPass: checks, |
| 124 | ReviewApproved: approved, |
| 125 | NoConflicts: noConflics, |
| 126 | Stacked: stacked, |
| 127 | }, |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | tests := []testcase{ |
| 132 | {pr(CheckStatusPass, true, true, true), cfg(true, true), "[vvvv]"}, |
| 133 | {pr(CheckStatusFail, true, true, true), cfg(true, true), "[xvvv]"}, |
| 134 | {pr(CheckStatusUnknown, true, true, true), cfg(true, true), "[?vvv]"}, |
| 135 | {pr(CheckStatusPending, true, true, true), cfg(true, true), "[.vvv]"}, |
| 136 | {pr(CheckStatusPass, false, true, true), cfg(true, true), "[vxvv]"}, |
| 137 | {pr(CheckStatusPass, true, false, true), cfg(true, true), "[vvxv]"}, |
| 138 | {pr(CheckStatusPass, true, true, false), cfg(true, true), "[vvvx]"}, |
| 139 | {pr(CheckStatusPass, true, true, true), cfg(false, true), "[-vvv]"}, |
| 140 | {pr(CheckStatusPass, true, true, true), cfg(false, false), "[--vv]"}, |
| 141 | } |
| 142 | for i, test := range tests { |
| 143 | assert.Equal(t, test.expect, test.pr.StatusString(test.cfg), fmt.Sprintf("case %d failed", i)) |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | func TestString(t *testing.T) { |
| 148 | type testcase struct { |
nothing calls this directly
no test coverage detected