(t *testing.T)
| 987 | } |
| 988 | |
| 989 | func Test_apiRun_paginationGraphQL(t *testing.T) { |
| 990 | ios, _, stdout, stderr := iostreams.Test() |
| 991 | |
| 992 | requestCount := 0 |
| 993 | responses := []*http.Response{ |
| 994 | { |
| 995 | StatusCode: 200, |
| 996 | Header: http.Header{"Content-Type": []string{`application/json`}}, |
| 997 | Body: io.NopCloser(bytes.NewBufferString(heredoc.Doc(` |
| 998 | { |
| 999 | "data": { |
| 1000 | "nodes": ["page one"], |
| 1001 | "pageInfo": { |
| 1002 | "endCursor": "PAGE1_END", |
| 1003 | "hasNextPage": true |
| 1004 | } |
| 1005 | } |
| 1006 | }`))), |
| 1007 | }, |
| 1008 | { |
| 1009 | StatusCode: 200, |
| 1010 | Header: http.Header{"Content-Type": []string{`application/json`}}, |
| 1011 | Body: io.NopCloser(bytes.NewBufferString(heredoc.Doc(` |
| 1012 | { |
| 1013 | "data": { |
| 1014 | "nodes": ["page two"], |
| 1015 | "pageInfo": { |
| 1016 | "endCursor": "PAGE2_END", |
| 1017 | "hasNextPage": false |
| 1018 | } |
| 1019 | } |
| 1020 | }`))), |
| 1021 | }, |
| 1022 | } |
| 1023 | |
| 1024 | options := ApiOptions{ |
| 1025 | IO: ios, |
| 1026 | HttpClient: func() (*http.Client, error) { |
| 1027 | var tr roundTripper = func(req *http.Request) (*http.Response, error) { |
| 1028 | resp := responses[requestCount] |
| 1029 | resp.Request = req |
| 1030 | requestCount++ |
| 1031 | return resp, nil |
| 1032 | } |
| 1033 | return &http.Client{Transport: tr}, nil |
| 1034 | }, |
| 1035 | Config: func() (gh.Config, error) { |
| 1036 | return config.NewMockConfig(), nil |
| 1037 | }, |
| 1038 | |
| 1039 | RawFields: []string{"foo=bar"}, |
| 1040 | RequestMethod: "POST", |
| 1041 | RequestPath: "graphql", |
| 1042 | Paginate: true, |
| 1043 | } |
| 1044 | |
| 1045 | err := apiRun(&options) |
| 1046 | require.NoError(t, err) |
nothing calls this directly
no test coverage detected