diff --git a/default_api.go b/default_api.go index 7fb8dc9..43e9024 100644 --- a/default_api.go +++ b/default_api.go @@ -724,7 +724,11 @@ func (a *DefaultApiService) CreateBranch(projectKey, repositorySlug string) (*AP @param optional (nil or map[string]interface{}) with one or more of: @param "since" (string) For a merge commit, a parent can be provided to specify which diff the comments should be on. For a commit range, a {@code sinceId} can be provided to specify where the comments should be anchored from. @return */ -func (a *DefaultApiService) CreateComment(projectKey, repositorySlug string, commitId string, comment Comment, localVarOptionals map[string]interface{}) (*APIResponse, error) { +func (a *DefaultApiService) CreateComment(projectKey, repositorySlug string, commitId string, localVarOptionals map[string]interface{}) (*APIResponse, error) { + return a.CreateCommentWithComment(projectKey, repositorySlug, commitId, Comment{}, localVarOptionals) +} + +func (a *DefaultApiService) CreateCommentWithComment(projectKey, repositorySlug string, commitId string, comment Comment, localVarOptionals map[string]interface{}) (*APIResponse, error) { var ( localVarHTTPMethod = strings.ToUpper("Post") localVarPostBody interface{} diff --git a/default_api_test.go b/default_api_test.go index d3c2c29..2e74628 100644 --- a/default_api_test.go +++ b/default_api_test.go @@ -654,6 +654,45 @@ func TestDefaultApiService_CreateBranch(t *testing.T) { } func TestDefaultApiService_CreateComment(t *testing.T) { + type fields struct { + client *APIClient + } + type args struct { + projectKey string + repositorySlug string + commitId string + localVarOptionals map[string]interface{} + } + tests := []struct { + name string + fields fields + args args + want *APIResponse + wantErr, integrationTest bool + }{ + {"networkErrorContextExceeded", fields{client: generateConfigFake()}, args{}, &APIResponse{Message: "Post https://stash.domain.com/rest/api/1.0/projects//repos//commits//comments: context canceled"}, true, false}, + } + for _, tt := range tests { + if tt.integrationTest != runIntegrationTests { + continue + } + t.Run(tt.name, func(t *testing.T) { + a := &DefaultApiService{ + client: tt.fields.client, + } + got, err := a.CreateComment(tt.args.projectKey, tt.args.repositorySlug, tt.args.commitId, tt.args.localVarOptionals) + if (err != nil) != tt.wantErr { + t.Errorf("DefaultApiService.CreateComment() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("DefaultApiService.CreateComment() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestDefaultApiService_CreateCommentWithComment(t *testing.T) { type fields struct { client *APIClient } @@ -700,16 +739,16 @@ func TestDefaultApiService_CreateComment(t *testing.T) { a := &DefaultApiService{ client: tt.fields.client, } - got, err := a.CreateComment(tt.args.projectKey, tt.args.repositorySlug, tt.args.commitId, tt.args.comment, tt.args.localVarOptionals) + got, err := a.CreateCommentWithComment(tt.args.projectKey, tt.args.repositorySlug, tt.args.commitId, tt.args.comment, tt.args.localVarOptionals) if (err != nil) != tt.wantErr { - t.Errorf("DefaultApiService.CreateComment() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf("DefaultApiService.CreateCommentWithComment() error = %v, wantErr %v", err, tt.wantErr) return } if got != nil { got.Response = nil } if !reflect.DeepEqual(got, tt.want) { - t.Errorf("DefaultApiService.CreateComment() = %v, want %v", got, tt.want) + t.Errorf("DefaultApiService.CreateCommentWithComment() = %v, want %v", got, tt.want) } }) }