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