(t *testing.T)
| 907 | } |
| 908 | |
| 909 | func Test_apiRun_paginationGraphQL(t *testing.T) { |
| 910 | ios, _, stdout, stderr := iostreams.Test() |
| 911 | |
| 912 | requestCount := 0 |
| 913 | responses := []*http.Response{ |
| 914 | { |
| 915 | StatusCode: 200, |
| 916 | Header: http.Header{"Content-Type": []string{`application/json`}}, |
| 917 | Body: io.NopCloser(bytes.NewBufferString(heredoc.Doc(` |
| 918 | { |
| 919 | "data": { |
| 920 | "nodes": ["page one"], |
| 921 | "pageInfo": { |
| 922 | "endCursor": "PAGE1_END", |
| 923 | "hasNextPage": true |
| 924 | } |
| 925 | } |
| 926 | }`))), |
| 927 | }, |
| 928 | { |
| 929 | StatusCode: 200, |
| 930 | Header: http.Header{"Content-Type": []string{`application/json`}}, |
| 931 | Body: io.NopCloser(bytes.NewBufferString(heredoc.Doc(` |
| 932 | { |
| 933 | "data": { |
| 934 | "nodes": ["page two"], |
| 935 | "pageInfo": { |
| 936 | "endCursor": "PAGE2_END", |
| 937 | "hasNextPage": false |
| 938 | } |
| 939 | } |
| 940 | }`))), |
| 941 | }, |
| 942 | } |
| 943 | |
| 944 | options := ApiOptions{ |
| 945 | IO: ios, |
| 946 | HttpClient: func() (*http.Client, error) { |
| 947 | var tr roundTripper = func(req *http.Request) (*http.Response, error) { |
| 948 | resp := responses[requestCount] |
| 949 | resp.Request = req |
| 950 | requestCount++ |
| 951 | return resp, nil |
| 952 | } |
| 953 | return &http.Client{Transport: tr}, nil |
| 954 | }, |
| 955 | Config: func() (gh.Config, error) { |
| 956 | return config.NewBlankConfig(), nil |
| 957 | }, |
| 958 | |
| 959 | RawFields: []string{"foo=bar"}, |
| 960 | RequestMethod: "POST", |
| 961 | RequestPath: "graphql", |
| 962 | Paginate: true, |
| 963 | } |
| 964 | |
| 965 | err := apiRun(&options) |
| 966 | require.NoError(t, err) |
nothing calls this directly
no test coverage detected