(t *testing.T)
| 189 | } |
| 190 | |
| 191 | func TestPRStatus_currentBranch_showTheMostRecentPR(t *testing.T) { |
| 192 | http := initFakeHTTP() |
| 193 | defer http.Verify(t) |
| 194 | http.Register(httpmock.GraphQL(`query PullRequestStatus\b`), httpmock.FileResponse("./fixtures/prStatusCurrentBranch.json")) |
| 195 | |
| 196 | // stub successful git command |
| 197 | rs, cleanup := run.Stub() |
| 198 | defer cleanup(t) |
| 199 | rs.Register(`git config --get-regexp \^branch\\.`, 0, "") |
| 200 | rs.Register(`git config remote.pushDefault`, 0, "") |
| 201 | rs.Register(`git rev-parse --symbolic-full-name blueberries@{push}`, 128, "") |
| 202 | rs.Register(`git config push.default`, 1, "") |
| 203 | |
| 204 | output, err := runCommand(http, "blueberries", true, "") |
| 205 | if err != nil { |
| 206 | t.Errorf("error running command `pr status`: %v", err) |
| 207 | } |
| 208 | |
| 209 | expectedLine := regexp.MustCompile(`#10 Blueberries are certainly a good fruit \[blueberries\]`) |
| 210 | if !expectedLine.MatchString(output.String()) { |
| 211 | t.Errorf("output did not match regexp /%s/\n> output\n%s\n", expectedLine, output) |
| 212 | return |
| 213 | } |
| 214 | |
| 215 | unexpectedLines := []*regexp.Regexp{ |
| 216 | regexp.MustCompile(`#9 Blueberries are a good fruit \[blueberries\] - Merged`), |
| 217 | regexp.MustCompile(`#8 Blueberries are probably a good fruit \[blueberries\] - Closed`), |
| 218 | } |
| 219 | for _, r := range unexpectedLines { |
| 220 | if r.MatchString(output.String()) { |
| 221 | t.Errorf("output unexpectedly match regexp /%s/\n> output\n%s\n", r, output) |
| 222 | return |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | func TestPRStatus_currentBranch_defaultBranch(t *testing.T) { |
| 228 | http := initFakeHTTP() |
nothing calls this directly
no test coverage detected