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

Function Test_apiRun_paginated_template

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

Source from the content-addressed store, hash-verified

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

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