MCPcopy
hub / github.com/cli/cli / Test_apiRun_paginated_template

Function Test_apiRun_paginated_template

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

Source from the content-addressed store, hash-verified

1109}
1110
1111func Test_apiRun_paginated_template(t *testing.T) {
1112 ios, _, stdout, stderr := iostreams.Test()
1113 ios.SetStdoutTTY(true)
1114
1115 requestCount := 0
1116 responses := []*http.Response{
1117 {
1118 StatusCode: 200,
1119 Header: http.Header{"Content-Type": []string{`application/json`}},
1120 Body: io.NopCloser(bytes.NewBufferString(`{
1121 "data": {
1122 "nodes": [
1123 {
1124 "page": 1,
1125 "caption": "page one"
1126 }
1127 ],
1128 "pageInfo": {
1129 "endCursor": "PAGE1_END",
1130 "hasNextPage": true
1131 }
1132 }
1133 }`)),
1134 },
1135 {
1136 StatusCode: 200,
1137 Header: http.Header{"Content-Type": []string{`application/json`}},
1138 Body: io.NopCloser(bytes.NewBufferString(`{
1139 "data": {
1140 "nodes": [
1141 {
1142 "page": 20,
1143 "caption": "page twenty"
1144 }
1145 ],
1146 "pageInfo": {
1147 "endCursor": "PAGE20_END",
1148 "hasNextPage": false
1149 }
1150 }
1151 }`)),
1152 },
1153 }
1154
1155 options := ApiOptions{
1156 IO: ios,
1157 HttpClient: func() (*http.Client, error) {
1158 var tr roundTripper = func(req *http.Request) (*http.Response, error) {
1159 resp := responses[requestCount]
1160 resp.Request = req
1161 requestCount++
1162 return resp, nil
1163 }
1164 return &http.Client{Transport: tr}, nil
1165 },
1166 Config: func() (gh.Config, error) {
1167 return config.NewBlankConfig(), nil
1168 },

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected