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

Function Test_apiRun_paginated_template

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

Source from the content-addressed store, hash-verified

1290}
1291
1292func Test_apiRun_paginated_template(t *testing.T) {
1293 ios, _, stdout, stderr := iostreams.Test()
1294 ios.SetStdoutTTY(true)
1295
1296 requestCount := 0
1297 responses := []*http.Response{
1298 {
1299 StatusCode: 200,
1300 Header: http.Header{"Content-Type": []string{`application/json`}},
1301 Body: io.NopCloser(bytes.NewBufferString(`{
1302 "data": {
1303 "nodes": [
1304 {
1305 "page": 1,
1306 "caption": "page one"
1307 }
1308 ],
1309 "pageInfo": {
1310 "endCursor": "PAGE1_END",
1311 "hasNextPage": true
1312 }
1313 }
1314 }`)),
1315 },
1316 {
1317 StatusCode: 200,
1318 Header: http.Header{"Content-Type": []string{`application/json`}},
1319 Body: io.NopCloser(bytes.NewBufferString(`{
1320 "data": {
1321 "nodes": [
1322 {
1323 "page": 20,
1324 "caption": "page twenty"
1325 }
1326 ],
1327 "pageInfo": {
1328 "endCursor": "PAGE20_END",
1329 "hasNextPage": false
1330 }
1331 }
1332 }`)),
1333 },
1334 }
1335
1336 options := ApiOptions{
1337 IO: ios,
1338 HttpClient: func(rootapi.HTTPClientOptions) (*http.Client, error) {
1339 var tr roundTripper = func(req *http.Request) (*http.Response, error) {
1340 resp := responses[requestCount]
1341 resp.Request = req
1342 requestCount++
1343 return resp, nil
1344 }
1345 return &http.Client{Transport: tr}, nil
1346 },
1347 Config: func() (gh.Config, error) {
1348 return config.NewMockConfig(), nil
1349 },

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected