(t *testing.T)
| 1006 | } |
| 1007 | |
| 1008 | func Test_apiRun_paginationGraphQL_slurp(t *testing.T) { |
| 1009 | ios, _, stdout, stderr := iostreams.Test() |
| 1010 | |
| 1011 | requestCount := 0 |
| 1012 | responses := []*http.Response{ |
| 1013 | { |
| 1014 | StatusCode: 200, |
| 1015 | Header: http.Header{"Content-Type": []string{`application/json`}}, |
| 1016 | Body: io.NopCloser(bytes.NewBufferString(heredoc.Doc(` |
| 1017 | { |
| 1018 | "data": { |
| 1019 | "nodes": ["page one"], |
| 1020 | "pageInfo": { |
| 1021 | "endCursor": "PAGE1_END", |
| 1022 | "hasNextPage": true |
| 1023 | } |
| 1024 | } |
| 1025 | }`))), |
| 1026 | }, |
| 1027 | { |
| 1028 | StatusCode: 200, |
| 1029 | Header: http.Header{"Content-Type": []string{`application/json`}}, |
| 1030 | Body: io.NopCloser(bytes.NewBufferString(heredoc.Doc(` |
| 1031 | { |
| 1032 | "data": { |
| 1033 | "nodes": ["page two"], |
| 1034 | "pageInfo": { |
| 1035 | "endCursor": "PAGE2_END", |
| 1036 | "hasNextPage": false |
| 1037 | } |
| 1038 | } |
| 1039 | }`))), |
| 1040 | }, |
| 1041 | } |
| 1042 | |
| 1043 | options := ApiOptions{ |
| 1044 | IO: ios, |
| 1045 | HttpClient: func() (*http.Client, error) { |
| 1046 | var tr roundTripper = func(req *http.Request) (*http.Response, error) { |
| 1047 | resp := responses[requestCount] |
| 1048 | resp.Request = req |
| 1049 | requestCount++ |
| 1050 | return resp, nil |
| 1051 | } |
| 1052 | return &http.Client{Transport: tr}, nil |
| 1053 | }, |
| 1054 | Config: func() (gh.Config, error) { |
| 1055 | return config.NewBlankConfig(), nil |
| 1056 | }, |
| 1057 | |
| 1058 | RawFields: []string{"foo=bar"}, |
| 1059 | RequestMethod: "POST", |
| 1060 | RequestPath: "graphql", |
| 1061 | Paginate: true, |
| 1062 | Slurp: true, |
| 1063 | } |
| 1064 | |
| 1065 | err := apiRun(&options) |
nothing calls this directly
no test coverage detected