MCPcopy Create free account
hub / github.com/cli/cli / TestPRStatus_currentBranch_showTheMostRecentPR

Function TestPRStatus_currentBranch_showTheMostRecentPR

pkg/cmd/pr/status/status_test.go:191–225  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

189}
190
191func 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
227func TestPRStatus_currentBranch_defaultBranch(t *testing.T) {
228 http := initFakeHTTP()

Callers

nothing calls this directly

Calls 9

GraphQLFunction · 0.92
FileResponseFunction · 0.92
StubFunction · 0.92
initFakeHTTPFunction · 0.70
runCommandFunction · 0.70
VerifyMethod · 0.65
ErrorfMethod · 0.65
StringMethod · 0.65
RegisterMethod · 0.45

Tested by

no test coverage detected