mirror of
https://github.com/gfleury/go-bitbucket-v1.git
synced 2025-04-04 17:00:12 -05:00
fix: support pagination for GetBranches
The docs mention that this is a Paged API, yet there is no support for limit and start query params.
This commit is contained in:
parent
dff2223ade
commit
4880bdf0b7
@ -3260,7 +3260,19 @@ func (a *DefaultApiService) GetBranches(project, repository string, localVarOpti
|
||||
if err := typeCheckParameter(localVarOptionals["orderBy"], "string", "orderBy"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := typeCheckParameter(localVarOptionals["limit"], "int", "limit"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := typeCheckParameter(localVarOptionals["start"], "int", "start"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if localVarTempParam, localVarOk := localVarOptionals["limit"].(int); localVarOk {
|
||||
localVarQueryParams.Add("limit", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["start"].(int); localVarOk {
|
||||
localVarQueryParams.Add("start", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["base"].(string); localVarOk {
|
||||
localVarQueryParams.Add("base", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
|
@ -5,6 +5,9 @@
|
||||
package bitbucketv1
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
@ -2331,6 +2334,47 @@ func TestDefaultApiService_GetBranches(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultApiService_GetBranchesPagination(t *testing.T) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
switch r.RequestURI {
|
||||
case "/api/1.0/projects/PROJECT/repos/REPO/branches?limit=100&start=0":
|
||||
io.WriteString(w, `{
|
||||
"size": 1,
|
||||
"limit": 100,
|
||||
"isLastPage": true,
|
||||
"values": [
|
||||
{
|
||||
"id": "refs/heads/main",
|
||||
"displayId": "main",
|
||||
"type": "BRANCH",
|
||||
"latestCommit": "8d51122def5632836d1cb1026e879069e10a1e13",
|
||||
"latestChangeset": "8d51122def5632836d1cb1026e879069e10a1e13",
|
||||
"isDefault": true
|
||||
}
|
||||
],
|
||||
"start": 0
|
||||
}`)
|
||||
default:
|
||||
t.Errorf("DefaultApiService.GetBranches() error = unhandled request %s", r.RequestURI)
|
||||
}
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
||||
client := NewAPIClient(
|
||||
context.TODO(),
|
||||
NewConfiguration(ts.URL),
|
||||
)
|
||||
_, err := client.DefaultApi.GetBranches("PROJECT", "REPO", map[string]interface{}{
|
||||
"limit": 100,
|
||||
"start": 0,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("DefaultApiService.GetBranches() error = %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultApiService_GetChanges(t *testing.T) {
|
||||
type fields struct {
|
||||
client *APIClient
|
||||
|
Loading…
x
Reference in New Issue
Block a user