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

Function TestPRStatus

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

Source from the content-addressed store, hash-verified

91}
92
93func 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
125func TestPRStatus_reviewsAndChecks(t *testing.T) {
126 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
RegisterMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected