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