Fixing CanMerge, Create and CountPullRequestTasks

This commit is contained in:
gfleury 2019-06-04 16:14:10 +02:00
parent 3a732135aa
commit 8602c101c8
2 changed files with 44 additions and 11 deletions

View File

@ -353,7 +353,7 @@ Test whether a pull request can be merged. <p> A pull request may not be
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param pullRequestId the ID of the pull request within the repository @param pullRequestId the ID of the pull request within the repository
@return */ @return */
func (a *DefaultApiService) CanMerge(pullRequestID int64) (*APIResponse, error) { func (a *DefaultApiService) CanMerge(projectKey, repositorySlug string, pullRequestID int64) (*APIResponse, error) {
var ( var (
localVarHTTPMethod = strings.ToUpper("Get") localVarHTTPMethod = strings.ToUpper("Get")
localVarPostBody interface{} localVarPostBody interface{}
@ -363,6 +363,8 @@ func (a *DefaultApiService) CanMerge(pullRequestID int64) (*APIResponse, error)
// create path and map variables // create path and map variables
localVarPath := a.client.cfg.BasePath + "/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/merge" localVarPath := a.client.cfg.BasePath + "/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/merge"
localVarPath = strings.Replace(localVarPath, "{"+"projectKey"+"}", fmt.Sprintf("%v", projectKey), -1)
localVarPath = strings.Replace(localVarPath, "{"+"repositorySlug"+"}", fmt.Sprintf("%v", repositorySlug), -1)
localVarPath = strings.Replace(localVarPath, "{"+"pullRequestId"+"}", fmt.Sprintf("%v", pullRequestID), -1) localVarPath = strings.Replace(localVarPath, "{"+"pullRequestId"+"}", fmt.Sprintf("%v", pullRequestID), -1)
localVarHeaderParams := make(map[string]string) localVarHeaderParams := make(map[string]string)
@ -525,7 +527,7 @@ func (a *DefaultApiService) ClearUserCaptchaChallenge(localVarOptionals map[stri
Retrieve the total number of {@link TaskState#OPEN open} and {@link TaskState#RESOLVED resolved} tasks associated with a pull request. Retrieve the total number of {@link TaskState#OPEN open} and {@link TaskState#RESOLVED resolved} tasks associated with a pull request.
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@return */ @return */
func (a *DefaultApiService) CountPullRequestTasks(ctx context.Context) (*APIResponse, error) { func (a *DefaultApiService) CountPullRequestTasks(projectKey, repositorySlug string, pullRequestId int64) (*APIResponse, error) {
var ( var (
localVarHTTPMethod = strings.ToUpper("Get") localVarHTTPMethod = strings.ToUpper("Get")
localVarPostBody interface{} localVarPostBody interface{}
@ -535,6 +537,9 @@ func (a *DefaultApiService) CountPullRequestTasks(ctx context.Context) (*APIResp
// create path and map variables // create path and map variables
localVarPath := a.client.cfg.BasePath + "/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/tasks/count" localVarPath := a.client.cfg.BasePath + "/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/tasks/count"
localVarPath = strings.Replace(localVarPath, "{"+"projectKey"+"}", fmt.Sprintf("%v", projectKey), -1)
localVarPath = strings.Replace(localVarPath, "{"+"repositorySlug"+"}", fmt.Sprintf("%v", repositorySlug), -1)
localVarPath = strings.Replace(localVarPath, "{"+"pullRequestId"+"}", fmt.Sprintf("%v", pullRequestId), -1)
localVarHeaderParams := make(map[string]string) localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
@ -579,7 +584,7 @@ func (a *DefaultApiService) CountPullRequestTasks(ctx context.Context) (*APIResp
Create a new pull request between two branches. The branches may be in the same repository, or different ones. When using different repositories, they must still be in the same {@link Repository#getHierarchyId() hierarchy}. <p> The authenticated user must have <strong>REPO_READ</strong> permission for the \"from\" and \"to\"repositories to call this resource. Create a new pull request between two branches. The branches may be in the same repository, or different ones. When using different repositories, they must still be in the same {@link Repository#getHierarchyId() hierarchy}. <p> The authenticated user must have <strong>REPO_READ</strong> permission for the \"from\" and \"to\"repositories to call this resource.
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@return */ @return */
func (a *DefaultApiService) Create(ctx context.Context) (*APIResponse, error) { func (a *DefaultApiService) Create(projectKey, repositorySlug string, localVarOptionals map[string]interface{}) (*APIResponse, error) {
var ( var (
localVarHTTPMethod = strings.ToUpper("Post") localVarHTTPMethod = strings.ToUpper("Post")
localVarPostBody interface{} localVarPostBody interface{}
@ -589,11 +594,33 @@ func (a *DefaultApiService) Create(ctx context.Context) (*APIResponse, error) {
// create path and map variables // create path and map variables
localVarPath := a.client.cfg.BasePath + "/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests" localVarPath := a.client.cfg.BasePath + "/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests"
localVarPath = strings.Replace(localVarPath, "{"+"projectKey"+"}", fmt.Sprintf("%v", projectKey), -1)
localVarPath = strings.Replace(localVarPath, "{"+"repositorySlug"+"}", fmt.Sprintf("%v", repositorySlug), -1)
localVarHeaderParams := make(map[string]string) localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
if err := typeCheckParameter(localVarOptionals["from"], "string", "from"); err != nil {
return nil, err
}
if err := typeCheckParameter(localVarOptionals["to"], "string", "to"); err != nil {
return nil, err
}
if err := typeCheckParameter(localVarOptionals["fromRepo"], "string", "fromRepo"); err != nil {
return nil, err
}
if localVarTempParam, localVarOk := localVarOptionals["from"].(string); localVarOk {
localVarQueryParams.Add("from", parameterToString(localVarTempParam, ""))
}
if localVarTempParam, localVarOk := localVarOptionals["to"].(string); localVarOk {
localVarQueryParams.Add("to", parameterToString(localVarTempParam, ""))
}
if localVarTempParam, localVarOk := localVarOptionals["fromRepo"].(string); localVarOk {
localVarQueryParams.Add("fromRepo", parameterToString(localVarTempParam, ""))
}
// to determine the Content-Type header // to determine the Content-Type header
localVarHTTPContentTypes := []string{} localVarHTTPContentTypes := []string{}

View File

@ -214,7 +214,9 @@ func TestDefaultApiService_CanMerge(t *testing.T) {
client *APIClient client *APIClient
} }
type args struct { type args struct {
pullRequestID int64 projectKey string
repositorySlug string
pullRequestID int64
} }
tests := []struct { tests := []struct {
name string name string
@ -230,7 +232,7 @@ func TestDefaultApiService_CanMerge(t *testing.T) {
a := &DefaultApiService{ a := &DefaultApiService{
client: tt.fields.client, client: tt.fields.client,
} }
got, err := a.CanMerge(tt.args.pullRequestID) got, err := a.CanMerge(tt.args.projectKey, tt.args.repositorySlug, tt.args.pullRequestID)
if (err != nil) != tt.wantErr { if (err != nil) != tt.wantErr {
t.Errorf("DefaultApiService.CanMerge() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("DefaultApiService.CanMerge() error = %v, wantErr %v", err, tt.wantErr)
return return
@ -313,7 +315,9 @@ func TestDefaultApiService_CountPullRequestTasks(t *testing.T) {
client *APIClient client *APIClient
} }
type args struct { type args struct {
ctx context.Context projectKey string
repositorySlug string
pullRequestId int64
} }
tests := []struct { tests := []struct {
name string name string
@ -329,7 +333,7 @@ func TestDefaultApiService_CountPullRequestTasks(t *testing.T) {
a := &DefaultApiService{ a := &DefaultApiService{
client: tt.fields.client, client: tt.fields.client,
} }
got, err := a.CountPullRequestTasks(tt.args.ctx) got, err := a.CountPullRequestTasks(tt.args.projectKey, tt.args.repositorySlug, tt.args.pullRequestId)
if (err != nil) != tt.wantErr { if (err != nil) != tt.wantErr {
t.Errorf("DefaultApiService.CountPullRequestTasks() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("DefaultApiService.CountPullRequestTasks() error = %v, wantErr %v", err, tt.wantErr)
return return
@ -346,7 +350,9 @@ func TestDefaultApiService_Create(t *testing.T) {
client *APIClient client *APIClient
} }
type args struct { type args struct {
ctx context.Context projectKey string
repositorySlug string
localVarOptionals map[string]interface{}
} }
tests := []struct { tests := []struct {
name string name string
@ -362,7 +368,7 @@ func TestDefaultApiService_Create(t *testing.T) {
a := &DefaultApiService{ a := &DefaultApiService{
client: tt.fields.client, client: tt.fields.client,
} }
got, err := a.Create(tt.args.ctx) got, err := a.Create(tt.args.projectKey, tt.args.repositorySlug, tt.args.localVarOptionals)
if (err != nil) != tt.wantErr { if (err != nil) != tt.wantErr {
t.Errorf("DefaultApiService.Create() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("DefaultApiService.Create() error = %v, wantErr %v", err, tt.wantErr)
return return
@ -2103,8 +2109,8 @@ func TestDefaultApiService_GetContent(t *testing.T) {
client *APIClient client *APIClient
} }
type args struct { type args struct {
projectKey string projectKey string
repositorySlug string repositorySlug string
localVarOptionals map[string]interface{} localVarOptionals map[string]interface{}
} }
tests := []struct { tests := []struct {