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