(t *testing.T)
| 1187 | } |
| 1188 | |
| 1189 | func Test_apiRun_paginationGraphQL_slurp(t *testing.T) { |
| 1190 | ios, _, stdout, stderr := iostreams.Test() |
| 1191 | |
| 1192 | requestCount := 0 |
| 1193 | responses := []*http.Response{ |
| 1194 | { |
| 1195 | StatusCode: 200, |
| 1196 | Header: http.Header{"Content-Type": []string{`application/json`}}, |
| 1197 | Body: io.NopCloser(bytes.NewBufferString(heredoc.Doc(` |
| 1198 | { |
| 1199 | "data": { |
| 1200 | "nodes": ["page one"], |
| 1201 | "pageInfo": { |
| 1202 | "endCursor": "PAGE1_END", |
| 1203 | "hasNextPage": true |
| 1204 | } |
| 1205 | } |
| 1206 | }`))), |
| 1207 | }, |
| 1208 | { |
| 1209 | StatusCode: 200, |
| 1210 | Header: http.Header{"Content-Type": []string{`application/json`}}, |
| 1211 | Body: io.NopCloser(bytes.NewBufferString(heredoc.Doc(` |
| 1212 | { |
| 1213 | "data": { |
| 1214 | "nodes": ["page two"], |
| 1215 | "pageInfo": { |
| 1216 | "endCursor": "PAGE2_END", |
| 1217 | "hasNextPage": false |
| 1218 | } |
| 1219 | } |
| 1220 | }`))), |
| 1221 | }, |
| 1222 | } |
| 1223 | |
| 1224 | options := ApiOptions{ |
| 1225 | IO: ios, |
| 1226 | HttpClient: func(rootapi.HTTPClientOptions) (*http.Client, error) { |
| 1227 | var tr roundTripper = func(req *http.Request) (*http.Response, error) { |
| 1228 | resp := responses[requestCount] |
| 1229 | resp.Request = req |
| 1230 | requestCount++ |
| 1231 | return resp, nil |
| 1232 | } |
| 1233 | return &http.Client{Transport: tr}, nil |
| 1234 | }, |
| 1235 | Config: func() (gh.Config, error) { |
| 1236 | return config.NewMockConfig(), nil |
| 1237 | }, |
| 1238 | |
| 1239 | RawFields: []string{"foo=bar"}, |
| 1240 | RequestMethod: "POST", |
| 1241 | RequestPath: "graphql", |
| 1242 | Paginate: true, |
| 1243 | Slurp: true, |
| 1244 | } |
| 1245 | |
| 1246 | err := apiRun(&options) |
nothing calls this directly
no test coverage detected