(t *testing.T)
| 2006 | } |
| 2007 | |
| 2008 | func TestResponse_cursorPagination(t *testing.T) { |
| 2009 | t.Parallel() |
| 2010 | r := http.Response{ |
| 2011 | Header: http.Header{ |
| 2012 | "Status": {"200 OK"}, |
| 2013 | "Link": {`<https://api.github.com/resource?per_page=2&page=url-encoded-next-page-token>; rel="next"`}, |
| 2014 | }, |
| 2015 | } |
| 2016 | |
| 2017 | response := newResponse(&r) |
| 2018 | if got, want := response.FirstPage, 0; got != want { |
| 2019 | t.Errorf("response.FirstPage: %v, want %v", got, want) |
| 2020 | } |
| 2021 | if got, want := response.PrevPage, 0; want != got { |
| 2022 | t.Errorf("response.PrevPage: %v, want %v", got, want) |
| 2023 | } |
| 2024 | if got, want := response.NextPage, 0; want != got { |
| 2025 | t.Errorf("response.NextPage: %v, want %v", got, want) |
| 2026 | } |
| 2027 | if got, want := response.LastPage, 0; want != got { |
| 2028 | t.Errorf("response.LastPage: %v, want %v", got, want) |
| 2029 | } |
| 2030 | if got, want := response.NextPageToken, "url-encoded-next-page-token"; want != got { |
| 2031 | t.Errorf("response.NextPageToken: %v, want %v", got, want) |
| 2032 | } |
| 2033 | |
| 2034 | // cursor-based pagination with "cursor" param |
| 2035 | r = http.Response{ |
| 2036 | Header: http.Header{ |
| 2037 | "Link": { |
| 2038 | `<https://api.github.com/?cursor=v1_12345678>; rel="next"`, |
| 2039 | }, |
| 2040 | }, |
| 2041 | } |
| 2042 | |
| 2043 | response = newResponse(&r) |
| 2044 | if got, want := response.Cursor, "v1_12345678"; got != want { |
| 2045 | t.Errorf("response.Cursor: %v, want %v", got, want) |
| 2046 | } |
| 2047 | } |
| 2048 | |
| 2049 | func TestResponse_beforeAfterPagination(t *testing.T) { |
| 2050 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…