(t *testing.T)
| 943 | } |
| 944 | |
| 945 | func Test_apiRun_arrayPaginationREST(t *testing.T) { |
| 946 | ios, _, stdout, stderr := iostreams.Test() |
| 947 | ios.SetStdoutTTY(false) |
| 948 | |
| 949 | requestCount := 0 |
| 950 | responses := []*http.Response{ |
| 951 | { |
| 952 | StatusCode: 200, |
| 953 | Body: io.NopCloser(bytes.NewBufferString(`[{"item":1},{"item":2}]`)), |
| 954 | Header: http.Header{ |
| 955 | "Content-Type": []string{"application/json"}, |
| 956 | "Link": []string{`<https://api.github.com/repositories/1227/issues?page=2>; rel="next", <https://api.github.com/repositories/1227/issues?page=4>; rel="last"`}, |
| 957 | }, |
| 958 | }, |
| 959 | { |
| 960 | StatusCode: 200, |
| 961 | Body: io.NopCloser(bytes.NewBufferString(`[{"item":3},{"item":4}]`)), |
| 962 | Header: http.Header{ |
| 963 | "Content-Type": []string{"application/json"}, |
| 964 | "Link": []string{`<https://api.github.com/repositories/1227/issues?page=3>; rel="next", <https://api.github.com/repositories/1227/issues?page=4>; rel="last"`}, |
| 965 | }, |
| 966 | }, |
| 967 | { |
| 968 | StatusCode: 200, |
| 969 | Body: io.NopCloser(bytes.NewBufferString(`[{"item":5}]`)), |
| 970 | Header: http.Header{ |
| 971 | "Content-Type": []string{"application/json"}, |
| 972 | "Link": []string{`<https://api.github.com/repositories/1227/issues?page=4>; rel="next", <https://api.github.com/repositories/1227/issues?page=4>; rel="last"`}, |
| 973 | }, |
| 974 | }, |
| 975 | { |
| 976 | StatusCode: 200, |
| 977 | Body: io.NopCloser(bytes.NewBufferString(`[]`)), |
| 978 | Header: http.Header{ |
| 979 | "Content-Type": []string{"application/json"}, |
| 980 | }, |
| 981 | }, |
| 982 | } |
| 983 | |
| 984 | options := ApiOptions{ |
| 985 | IO: ios, |
| 986 | HttpClient: func(rootapi.HTTPClientOptions) (*http.Client, error) { |
| 987 | var tr roundTripper = func(req *http.Request) (*http.Response, error) { |
| 988 | resp := responses[requestCount] |
| 989 | resp.Request = req |
| 990 | requestCount++ |
| 991 | return resp, nil |
| 992 | } |
| 993 | return &http.Client{Transport: tr}, nil |
| 994 | }, |
| 995 | Config: func() (gh.Config, error) { |
| 996 | return config.NewMockConfig(), nil |
| 997 | }, |
| 998 | |
| 999 | RequestMethod: "GET", |
| 1000 | RequestMethodPassed: true, |
| 1001 | RequestPath: "issues", |
| 1002 | Paginate: true, |
nothing calls this directly
no test coverage detected