From deebb22b5d04abb63862c0bbdf0841ff1ccdf300 Mon Sep 17 00:00:00 2001 From: Luke Kysow <1034429+lkysow@users.noreply.github.com> Date: Fri, 16 Nov 2018 13:38:29 -0500 Subject: [PATCH] Use int instead of string for bitbucket response. --- server/events/vcs/bitbucketserver/client.go | 4 ++-- server/events/vcs/bitbucketserver/client_test.go | 2 +- server/events/vcs/bitbucketserver/models.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/events/vcs/bitbucketserver/client.go b/server/events/vcs/bitbucketserver/client.go index d9a3668f01..e7def0edeb 100644 --- a/server/events/vcs/bitbucketserver/client.go +++ b/server/events/vcs/bitbucketserver/client.go @@ -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 } diff --git a/server/events/vcs/bitbucketserver/client_test.go b/server/events/vcs/bitbucketserver/client_test.go index 810017854a..47b57c071e 100644 --- a/server/events/vcs/bitbucketserver/client_test.go +++ b/server/events/vcs/bitbucketserver/client_test.go @@ -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. diff --git a/server/events/vcs/bitbucketserver/models.go b/server/events/vcs/bitbucketserver/models.go index d1d8333d62..ba0ac0e514 100644 --- a/server/events/vcs/bitbucketserver/models.go +++ b/server/events/vcs/bitbucketserver/models.go @@ -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"` }