Use int instead of string for bitbucket response.

This commit is contained in:
Luke Kysow
2018-11-16 13:38:29 -05:00
parent d52b3fd870
commit deebb22b5d
3 changed files with 5 additions and 5 deletions

View File

@@ -63,13 +63,13 @@ func (b *Client) GetModifiedFiles(repo models.Repo, pull models.PullRequest) ([]
if err != nil {
return nil, err
}
nextPageStart := "0"
nextPageStart := 0
baseURL := fmt.Sprintf("%s/rest/api/1.0/projects/%s/repos/%s/pull-requests/%d/changes",
b.BaseURL, projectKey, repo.Name, pull.Num)
// We'll only loop 1000 times as a safety measure.
maxLoops := 1000
for i := 0; i < maxLoops; i++ {
resp, err := b.makeRequest("GET", fmt.Sprintf("%s?start=%s", baseURL, nextPageStart), nil)
resp, err := b.makeRequest("GET", fmt.Sprintf("%s?start=%d", baseURL, nextPageStart), nil)
if err != nil {
return nil, err
}

View File

@@ -45,7 +45,7 @@ func TestClient_GetModifiedFilesPagination(t *testing.T) {
// The first request should hit this URL.
case "/rest/api/1.0/projects/ow/repos/repo/pull-requests/1/changes?start=0":
resp := strings.Replace(firstResp, `"isLastPage": true`, `"isLastPage": false`, -1)
resp = strings.Replace(resp, `"nextPageStart": null`, `"nextPageStart": "3"`, -1)
resp = strings.Replace(resp, `"nextPageStart": null`, `"nextPageStart": 3`, -1)
w.Write([]byte(resp)) // nolint: errcheck
return
// The second should hit this URL.

View File

@@ -61,6 +61,6 @@ type Changes struct {
ToString *string `json:"toString,omitempty" validate:"required"`
} `json:"path,omitempty" validate:"required"`
} `json:"values,omitempty" validate:"required"`
NextPageStart *string `json:"nextPageStart,omitempty"`
IsLastPage *bool `json:"isLastPage,omitempty" validate:"required"`
NextPageStart *int `json:"nextPageStart,omitempty"`
IsLastPage *bool `json:"isLastPage,omitempty" validate:"required"`
}