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

Function Test_apiRun_paginationGraphQL_slurp

pkg/cmd/api/api_test.go:1120–1221  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1118}
1119
1120func Test_apiRun_paginationGraphQL_slurp(t *testing.T) {
1121 ios, _, stdout, stderr := iostreams.Test()
1122
1123 requestCount := 0
1124 responses := []*http.Response{
1125 {
1126 StatusCode: 200,
1127 Header: http.Header{"Content-Type": []string{`application/json`}},
1128 Body: io.NopCloser(bytes.NewBufferString(heredoc.Doc(`
1129 {
1130 "data": {
1131 "nodes": ["page one"],
1132 "pageInfo": {
1133 "endCursor": "PAGE1_END",
1134 "hasNextPage": true
1135 }
1136 }
1137 }`))),
1138 },
1139 {
1140 StatusCode: 200,
1141 Header: http.Header{"Content-Type": []string{`application/json`}},
1142 Body: io.NopCloser(bytes.NewBufferString(heredoc.Doc(`
1143 {
1144 "data": {
1145 "nodes": ["page two"],
1146 "pageInfo": {
1147 "endCursor": "PAGE2_END",
1148 "hasNextPage": false
1149 }
1150 }
1151 }`))),
1152 },
1153 }
1154
1155 options := ApiOptions{
1156 IO: ios,
1157 HttpClient: func(rootapi.HTTPClientOptions) (*http.Client, error) {
1158 var tr roundTripper = func(req *http.Request) (*http.Response, error) {
1159 resp := responses[requestCount]
1160 resp.Request = req
1161 requestCount++
1162 return resp, nil
1163 }
1164 return &http.Client{Transport: tr}, nil
1165 },
1166 Config: func() (gh.Config, error) {
1167 return config.NewMockConfig(), nil
1168 },
1169
1170 RawFields: []string{"foo=bar"},
1171 RequestMethod: "POST",
1172 RequestPath: "graphql",
1173 Paginate: true,
1174 Slurp: true,
1175 }
1176
1177 err := apiRun(&options)

Callers

nothing calls this directly

Calls 5

TestFunction · 0.92
NewMockConfigFunction · 0.92
apiRunFunction · 0.85
EqualMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected