(t *testing.T)
| 191 | } |
| 192 | |
| 193 | func TestRESTWithNext(t *testing.T) { |
| 194 | reg := &httpmock.Registry{} |
| 195 | defer reg.Verify(t) |
| 196 | client := newTestClient(reg) |
| 197 | |
| 198 | reg.Register(httpmock.MatchAny, func(req *http.Request) (*http.Response, error) { |
| 199 | return &http.Response{ |
| 200 | Request: req, |
| 201 | StatusCode: http.StatusOK, |
| 202 | Body: io.NopCloser(bytes.NewBufferString(`{"name": "item"}`)), |
| 203 | Header: http.Header{ |
| 204 | "Content-Type": {"application/json"}, |
| 205 | "Link": {`<https://api.github.com/repos/owner/repo/items?page=2>; rel="next", <https://api.github.com/repos/owner/repo/items?page=3>; rel="last"`}, |
| 206 | }, |
| 207 | }, nil |
| 208 | }) |
| 209 | |
| 210 | response := struct { |
| 211 | Name string `json:"name"` |
| 212 | }{} |
| 213 | next, err := client.RESTWithNext("github.com", http.MethodGet, "repos/owner/repo/items", nil, &response) |
| 214 | |
| 215 | require.NoError(t, err) |
| 216 | assert.Equal(t, "item", response.Name) |
| 217 | assert.Equal(t, "https://api.github.com/repos/owner/repo/items?page=2", next) |
| 218 | } |
| 219 | |
| 220 | func TestRESTWithNextNoContent(t *testing.T) { |
| 221 | reg := &httpmock.Registry{} |
nothing calls this directly
no test coverage detected