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

Function Test_apiRun_paginated_template

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

Source from the content-addressed store, hash-verified

1189}
1190
1191func Test_apiRun_paginated_template(t *testing.T) {
1192 ios, _, stdout, stderr := iostreams.Test()
1193 ios.SetStdoutTTY(true)
1194
1195 requestCount := 0
1196 responses := []*http.Response{
1197 {
1198 StatusCode: 200,
1199 Header: http.Header{"Content-Type": []string{`application/json`}},
1200 Body: io.NopCloser(bytes.NewBufferString(`{
1201 "data": {
1202 "nodes": [
1203 {
1204 "page": 1,
1205 "caption": "page one"
1206 }
1207 ],
1208 "pageInfo": {
1209 "endCursor": "PAGE1_END",
1210 "hasNextPage": true
1211 }
1212 }
1213 }`)),
1214 },
1215 {
1216 StatusCode: 200,
1217 Header: http.Header{"Content-Type": []string{`application/json`}},
1218 Body: io.NopCloser(bytes.NewBufferString(`{
1219 "data": {
1220 "nodes": [
1221 {
1222 "page": 20,
1223 "caption": "page twenty"
1224 }
1225 ],
1226 "pageInfo": {
1227 "endCursor": "PAGE20_END",
1228 "hasNextPage": false
1229 }
1230 }
1231 }`)),
1232 },
1233 }
1234
1235 options := ApiOptions{
1236 IO: ios,
1237 HttpClient: func() (*http.Client, error) {
1238 var tr roundTripper = func(req *http.Request) (*http.Response, error) {
1239 resp := responses[requestCount]
1240 resp.Request = req
1241 requestCount++
1242 return resp, nil
1243 }
1244 return &http.Client{Transport: tr}, nil
1245 },
1246 Config: func() (gh.Config, error) {
1247 return config.NewBlankConfig(), nil
1248 },

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected