MCPcopy
hub / github.com/cli/cli / TestIssueList

Function TestIssueList

pkg/cmd/issue/list/http_test.go:17–86  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestIssueList(t *testing.T) {
18 reg := &httpmock.Registry{}
19 httpClient := &http.Client{}
20 httpmock.ReplaceTripper(httpClient, reg)
21 client := api.NewClientFromHTTP(httpClient)
22
23 reg.Register(
24 httpmock.GraphQL(`query IssueList\b`),
25 httpmock.StringResponse(`
26 { "data": { "repository": {
27 "hasIssuesEnabled": true,
28 "issues": {
29 "nodes": [],
30 "pageInfo": {
31 "hasNextPage": true,
32 "endCursor": "ENDCURSOR"
33 }
34 }
35 } } }
36 `),
37 )
38 reg.Register(
39 httpmock.GraphQL(`query IssueList\b`),
40 httpmock.StringResponse(`
41 { "data": { "repository": {
42 "hasIssuesEnabled": true,
43 "issues": {
44 "nodes": [],
45 "pageInfo": {
46 "hasNextPage": false,
47 "endCursor": "ENDCURSOR"
48 }
49 }
50 } } }
51 `),
52 )
53
54 repo, _ := ghrepo.FromFullName("OWNER/REPO")
55 filters := prShared.FilterOptions{
56 Entity: "issue",
57 State: "open",
58 }
59 _, err := listIssues(client, repo, filters, 251)
60 if err != nil {
61 t.Fatalf("unexpected error: %v", err)
62 }
63
64 if len(reg.Requests) != 2 {
65 t.Fatalf("expected 2 HTTP requests, seen %d", len(reg.Requests))
66 }
67 var reqBody struct {
68 Query string
69 Variables map[string]interface{}
70 }
71
72 bodyBytes, _ := io.ReadAll(reg.Requests[0].Body)
73 _ = json.Unmarshal(bodyBytes, &reqBody)
74 if reqLimit := reqBody.Variables["limit"].(float64); reqLimit != 100 {

Callers

nothing calls this directly

Calls 9

RegisterMethod · 0.95
ReplaceTripperFunction · 0.92
NewClientFromHTTPFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
FromFullNameFunction · 0.92
listIssuesFunction · 0.85
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected