(t *testing.T)
| 1290 | } |
| 1291 | |
| 1292 | func 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 | }, |
nothing calls this directly
no test coverage detected