(t *testing.T)
| 129 | } |
| 130 | |
| 131 | func Test_checksRun(t *testing.T) { |
| 132 | tests := []struct { |
| 133 | name string |
| 134 | tty bool |
| 135 | watch bool |
| 136 | failFast bool |
| 137 | required bool |
| 138 | disableDetector bool |
| 139 | httpStubs func(*httpmock.Registry) |
| 140 | wantOut string |
| 141 | wantErr string |
| 142 | }{ |
| 143 | { |
| 144 | name: "no commits tty", |
| 145 | tty: true, |
| 146 | httpStubs: func(reg *httpmock.Registry) { |
| 147 | reg.Register( |
| 148 | httpmock.GraphQL(`query PullRequestStatusChecks\b`), |
| 149 | httpmock.StringResponse(`{"data":{"node":{}}}`), |
| 150 | ) |
| 151 | }, |
| 152 | wantOut: "", |
| 153 | wantErr: "no commit found on the pull request", |
| 154 | }, |
| 155 | { |
| 156 | name: "no checks tty", |
| 157 | tty: true, |
| 158 | httpStubs: func(reg *httpmock.Registry) { |
| 159 | reg.Register( |
| 160 | httpmock.GraphQL(`query PullRequestStatusChecks\b`), |
| 161 | httpmock.StringResponse(`{"data":{"node":{"statusCheckRollup":{"nodes":[{"commit":{"oid": "abc"}}]}}}}`), |
| 162 | ) |
| 163 | }, |
| 164 | wantOut: "", |
| 165 | wantErr: "no checks reported on the 'trunk' branch", |
| 166 | }, |
| 167 | { |
| 168 | name: "some failing tty", |
| 169 | tty: true, |
| 170 | httpStubs: func(reg *httpmock.Registry) { |
| 171 | reg.Register( |
| 172 | httpmock.GraphQL(`query PullRequestStatusChecks\b`), |
| 173 | httpmock.FileResponse("./fixtures/someFailing.json"), |
| 174 | ) |
| 175 | }, |
| 176 | wantOut: heredoc.Doc(` |
| 177 | Some checks were not successful |
| 178 | 0 cancelled, 1 failing, 1 successful, 0 skipped, and 1 pending checks |
| 179 | |
| 180 | NAME DESCRIPTION ELAPSED URL |
| 181 | X sad tests 1m26s sweet link |
| 182 | ✓ cool tests 1m26s sweet link |
| 183 | * slow tests 1m26s sweet link |
| 184 | `), |
| 185 | wantErr: "SilentError", |
| 186 | }, |
| 187 | { |
| 188 | name: "some cancelled tty", |
nothing calls this directly
no test coverage detected