Do not change signature of old CreateComment method

This commit is contained in:
Rashit Azizbaev 2021-01-19 08:51:30 +03:00
parent 3a28116813
commit c08e6350a4
2 changed files with 47 additions and 4 deletions

View File

@ -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{}

View File

@ -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)
}
})
}