(t *testing.T)
| 842 | } |
| 843 | |
| 844 | func Test_apiRun_arrayPaginationREST(t *testing.T) { |
| 845 | ios, _, stdout, stderr := iostreams.Test() |
| 846 | ios.SetStdoutTTY(false) |
| 847 | |
| 848 | requestCount := 0 |
| 849 | responses := []*http.Response{ |
| 850 | { |
| 851 | StatusCode: 200, |
| 852 | Body: io.NopCloser(bytes.NewBufferString(`[{"item":1},{"item":2}]`)), |
| 853 | Header: http.Header{ |
| 854 | "Content-Type": []string{"application/json"}, |
| 855 | "Link": []string{`<https://api.github.com/repositories/1227/issues?page=2>; rel="next", <https://api.github.com/repositories/1227/issues?page=4>; rel="last"`}, |
| 856 | }, |
| 857 | }, |
| 858 | { |
| 859 | StatusCode: 200, |
| 860 | Body: io.NopCloser(bytes.NewBufferString(`[{"item":3},{"item":4}]`)), |
| 861 | Header: http.Header{ |
| 862 | "Content-Type": []string{"application/json"}, |
| 863 | "Link": []string{`<https://api.github.com/repositories/1227/issues?page=3>; rel="next", <https://api.github.com/repositories/1227/issues?page=4>; rel="last"`}, |
| 864 | }, |
| 865 | }, |
| 866 | { |
| 867 | StatusCode: 200, |
| 868 | Body: io.NopCloser(bytes.NewBufferString(`[{"item":5}]`)), |
| 869 | Header: http.Header{ |
| 870 | "Content-Type": []string{"application/json"}, |
| 871 | "Link": []string{`<https://api.github.com/repositories/1227/issues?page=4>; rel="next", <https://api.github.com/repositories/1227/issues?page=4>; rel="last"`}, |
| 872 | }, |
| 873 | }, |
| 874 | { |
| 875 | StatusCode: 200, |
| 876 | Body: io.NopCloser(bytes.NewBufferString(`[]`)), |
| 877 | Header: http.Header{ |
| 878 | "Content-Type": []string{"application/json"}, |
| 879 | }, |
| 880 | }, |
| 881 | } |
| 882 | |
| 883 | options := ApiOptions{ |
| 884 | IO: ios, |
| 885 | HttpClient: func() (*http.Client, error) { |
| 886 | var tr roundTripper = func(req *http.Request) (*http.Response, error) { |
| 887 | resp := responses[requestCount] |
| 888 | resp.Request = req |
| 889 | requestCount++ |
| 890 | return resp, nil |
| 891 | } |
| 892 | return &http.Client{Transport: tr}, nil |
| 893 | }, |
| 894 | Config: func() (gh.Config, error) { |
| 895 | return config.NewMockConfig(), nil |
| 896 | }, |
| 897 | |
| 898 | RequestMethod: "GET", |
| 899 | RequestMethodPassed: true, |
| 900 | RequestPath: "issues", |
| 901 | Paginate: true, |
nothing calls this directly
no test coverage detected