(t *testing.T)
| 91 | } |
| 92 | |
| 93 | func TestPRStatus(t *testing.T) { |
| 94 | http := initFakeHTTP() |
| 95 | defer http.Verify(t) |
| 96 | http.Register(httpmock.GraphQL(`query PullRequestStatus\b`), httpmock.FileResponse("./fixtures/prStatus.json")) |
| 97 | |
| 98 | // stub successful git commands |
| 99 | rs, cleanup := run.Stub() |
| 100 | defer cleanup(t) |
| 101 | rs.Register(`git rev-parse --symbolic-full-name blueberries@{push}`, 128, "") |
| 102 | rs.Register(`git config --get-regexp \^branch\\.`, 0, "") |
| 103 | rs.Register(`git config remote.pushDefault`, 0, "") |
| 104 | rs.Register(`git config push.default`, 1, "") |
| 105 | |
| 106 | output, err := runCommand(http, "blueberries", true, "") |
| 107 | if err != nil { |
| 108 | t.Errorf("error running command `pr status`: %v", err) |
| 109 | } |
| 110 | |
| 111 | expectedPrs := []*regexp.Regexp{ |
| 112 | regexp.MustCompile(`#8.*\[strawberries\]`), |
| 113 | regexp.MustCompile(`#9.*\[apples\].*✓ Auto-merge enabled`), |
| 114 | regexp.MustCompile(`#10.*\[blueberries\]`), |
| 115 | regexp.MustCompile(`#11.*\[figs\]`), |
| 116 | } |
| 117 | |
| 118 | for _, r := range expectedPrs { |
| 119 | if !r.MatchString(output.String()) { |
| 120 | t.Errorf("output did not match regexp /%s/", r) |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | func TestPRStatus_reviewsAndChecks(t *testing.T) { |
| 126 | http := initFakeHTTP() |
nothing calls this directly
no test coverage detected