(t *testing.T)
| 1086 | } |
| 1087 | |
| 1088 | func Test_apiRun_paginationGraphQL_slurp(t *testing.T) { |
| 1089 | ios, _, stdout, stderr := iostreams.Test() |
| 1090 | |
| 1091 | requestCount := 0 |
| 1092 | responses := []*http.Response{ |
| 1093 | { |
| 1094 | StatusCode: 200, |
| 1095 | Header: http.Header{"Content-Type": []string{`application/json`}}, |
| 1096 | Body: io.NopCloser(bytes.NewBufferString(heredoc.Doc(` |
| 1097 | { |
| 1098 | "data": { |
| 1099 | "nodes": ["page one"], |
| 1100 | "pageInfo": { |
| 1101 | "endCursor": "PAGE1_END", |
| 1102 | "hasNextPage": true |
| 1103 | } |
| 1104 | } |
| 1105 | }`))), |
| 1106 | }, |
| 1107 | { |
| 1108 | StatusCode: 200, |
| 1109 | Header: http.Header{"Content-Type": []string{`application/json`}}, |
| 1110 | Body: io.NopCloser(bytes.NewBufferString(heredoc.Doc(` |
| 1111 | { |
| 1112 | "data": { |
| 1113 | "nodes": ["page two"], |
| 1114 | "pageInfo": { |
| 1115 | "endCursor": "PAGE2_END", |
| 1116 | "hasNextPage": false |
| 1117 | } |
| 1118 | } |
| 1119 | }`))), |
| 1120 | }, |
| 1121 | } |
| 1122 | |
| 1123 | options := ApiOptions{ |
| 1124 | IO: ios, |
| 1125 | HttpClient: func() (*http.Client, error) { |
| 1126 | var tr roundTripper = func(req *http.Request) (*http.Response, error) { |
| 1127 | resp := responses[requestCount] |
| 1128 | resp.Request = req |
| 1129 | requestCount++ |
| 1130 | return resp, nil |
| 1131 | } |
| 1132 | return &http.Client{Transport: tr}, nil |
| 1133 | }, |
| 1134 | Config: func() (gh.Config, error) { |
| 1135 | return config.NewBlankConfig(), nil |
| 1136 | }, |
| 1137 | |
| 1138 | RawFields: []string{"foo=bar"}, |
| 1139 | RequestMethod: "POST", |
| 1140 | RequestPath: "graphql", |
| 1141 | Paginate: true, |
| 1142 | Slurp: true, |
| 1143 | } |
| 1144 | |
| 1145 | err := apiRun(&options) |
nothing calls this directly
no test coverage detected