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

Function Test_apiRun_paginationGraphQL_slurp

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

Source from the content-addressed store, hash-verified

1188}
1189
1190func Test_apiRun_paginationGraphQL_slurp(t *testing.T) {
1191 ios, _, stdout, stderr := iostreams.Test()
1192
1193 requestCount := 0
1194 responses := []*http.Response{
1195 {
1196 StatusCode: 200,
1197 Header: http.Header{"Content-Type": []string{`application/json`}},
1198 Body: io.NopCloser(bytes.NewBufferString(heredoc.Doc(`
1199 {
1200 "data": {
1201 "nodes": ["page one"],
1202 "pageInfo": {
1203 "endCursor": "PAGE1_END",
1204 "hasNextPage": true
1205 }
1206 }
1207 }`))),
1208 },
1209 {
1210 StatusCode: 200,
1211 Header: http.Header{"Content-Type": []string{`application/json`}},
1212 Body: io.NopCloser(bytes.NewBufferString(heredoc.Doc(`
1213 {
1214 "data": {
1215 "nodes": ["page two"],
1216 "pageInfo": {
1217 "endCursor": "PAGE2_END",
1218 "hasNextPage": false
1219 }
1220 }
1221 }`))),
1222 },
1223 }
1224
1225 options := ApiOptions{
1226 IO: ios,
1227 HttpClient: func(rootapi.HTTPClientOptions) (*http.Client, error) {
1228 var tr roundTripper = func(req *http.Request) (*http.Response, error) {
1229 resp := responses[requestCount]
1230 resp.Request = req
1231 requestCount++
1232 return resp, nil
1233 }
1234 return &http.Client{Transport: tr}, nil
1235 },
1236 Config: func() (gh.Config, error) {
1237 return config.NewMockConfig(), nil
1238 },
1239
1240 RawFields: []string{"foo=bar"},
1241 RequestMethod: "POST",
1242 RequestPath: "graphql",
1243 Paginate: true,
1244 Slurp: true,
1245 }
1246
1247 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