(t *testing.T)
| 914 | } |
| 915 | |
| 916 | func Test_apiRun_arrayPaginationREST_with_headers(t *testing.T) { |
| 917 | ios, _, stdout, stderr := iostreams.Test() |
| 918 | |
| 919 | requestCount := 0 |
| 920 | responses := []*http.Response{ |
| 921 | { |
| 922 | Proto: "HTTP/1.1", |
| 923 | Status: "200 OK", |
| 924 | StatusCode: 200, |
| 925 | Body: io.NopCloser(bytes.NewBufferString(`[{"page":1}]`)), |
| 926 | Header: http.Header{ |
| 927 | "Content-Type": []string{"application/json"}, |
| 928 | "Link": []string{`<https://api.github.com/repositories/1227/issues?page=2>; rel="next", <https://api.github.com/repositories/1227/issues?page=3>; rel="last"`}, |
| 929 | "X-Github-Request-Id": []string{"1"}, |
| 930 | }, |
| 931 | }, |
| 932 | { |
| 933 | Proto: "HTTP/1.1", |
| 934 | Status: "200 OK", |
| 935 | StatusCode: 200, |
| 936 | Body: io.NopCloser(bytes.NewBufferString(`[{"page":2}]`)), |
| 937 | Header: http.Header{ |
| 938 | "Content-Type": []string{"application/json"}, |
| 939 | "Link": []string{`<https://api.github.com/repositories/1227/issues?page=3>; rel="next", <https://api.github.com/repositories/1227/issues?page=3>; rel="last"`}, |
| 940 | "X-Github-Request-Id": []string{"2"}, |
| 941 | }, |
| 942 | }, |
| 943 | { |
| 944 | Proto: "HTTP/1.1", |
| 945 | Status: "200 OK", |
| 946 | StatusCode: 200, |
| 947 | Body: io.NopCloser(bytes.NewBufferString(`[{"page":3}]`)), |
| 948 | Header: http.Header{ |
| 949 | "Content-Type": []string{"application/json"}, |
| 950 | "X-Github-Request-Id": []string{"3"}, |
| 951 | }, |
| 952 | }, |
| 953 | } |
| 954 | |
| 955 | options := ApiOptions{ |
| 956 | IO: ios, |
| 957 | HttpClient: func() (*http.Client, error) { |
| 958 | var tr roundTripper = func(req *http.Request) (*http.Response, error) { |
| 959 | resp := responses[requestCount] |
| 960 | resp.Request = req |
| 961 | requestCount++ |
| 962 | return resp, nil |
| 963 | } |
| 964 | return &http.Client{Transport: tr}, nil |
| 965 | }, |
| 966 | Config: func() (gh.Config, error) { |
| 967 | return config.NewBlankConfig(), nil |
| 968 | }, |
| 969 | |
| 970 | RequestMethod: "GET", |
| 971 | RequestMethodPassed: true, |
| 972 | RequestPath: "issues", |
| 973 | Paginate: true, |
nothing calls this directly
no test coverage detected