MCPcopy
hub / github.com/cli/cli / TestIssueStatus

Function TestIssueStatus

pkg/cmd/issue/status/status_test.go:58–87  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

56}
57
58func TestIssueStatus(t *testing.T) {
59 http := &httpmock.Registry{}
60 defer http.Verify(t)
61
62 http.Register(
63 httpmock.GraphQL(`query UserCurrent\b`),
64 httpmock.StringResponse(`{"data":{"viewer":{"login":"octocat"}}}`))
65 http.Register(
66 httpmock.GraphQL(`query IssueStatus\b`),
67 httpmock.FileResponse("./fixtures/issueStatus.json"))
68
69 output, err := runCommand(http, true, "")
70 if err != nil {
71 t.Errorf("error running command `issue status`: %v", err)
72 }
73
74 expectedIssues := []*regexp.Regexp{
75 regexp.MustCompile(`(?m)8.*carrots.*about.*ago`),
76 regexp.MustCompile(`(?m)9.*squash.*about.*ago`),
77 regexp.MustCompile(`(?m)10.*broccoli.*about.*ago`),
78 regexp.MustCompile(`(?m)11.*swiss chard.*about.*ago`),
79 }
80
81 for _, r := range expectedIssues {
82 if !r.MatchString(output.String()) {
83 t.Errorf("output did not match regexp /%s/\n> output\n%s\n", r, output)
84 return
85 }
86 }
87}
88
89func TestIssueStatus_blankSlate(t *testing.T) {
90 http := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 8

VerifyMethod · 0.95
RegisterMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
FileResponseFunction · 0.92
runCommandFunction · 0.70
ErrorfMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected