Skip to content

Commit c08e635

Browse files
committed
Do not change signature of old CreateComment method
1 parent 3a28116 commit c08e635

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

default_api.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,11 @@ func (a *DefaultApiService) CreateBranch(projectKey, repositorySlug string) (*AP
724724
@param optional (nil or map[string]interface{}) with one or more of:
725725
@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.
726726
@return */
727-
func (a *DefaultApiService) CreateComment(projectKey, repositorySlug string, commitId string, comment Comment, localVarOptionals map[string]interface{}) (*APIResponse, error) {
727+
func (a *DefaultApiService) CreateComment(projectKey, repositorySlug string, commitId string, localVarOptionals map[string]interface{}) (*APIResponse, error) {
728+
return a.CreateCommentWithComment(projectKey, repositorySlug, commitId, Comment{}, localVarOptionals)
729+
}
730+
731+
func (a *DefaultApiService) CreateCommentWithComment(projectKey, repositorySlug string, commitId string, comment Comment, localVarOptionals map[string]interface{}) (*APIResponse, error) {
728732
var (
729733
localVarHTTPMethod = strings.ToUpper("Post")
730734
localVarPostBody interface{}

default_api_test.go

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,45 @@ func TestDefaultApiService_CreateBranch(t *testing.T) {
654654
}
655655

656656
func TestDefaultApiService_CreateComment(t *testing.T) {
657+
type fields struct {
658+
client *APIClient
659+
}
660+
type args struct {
661+
projectKey string
662+
repositorySlug string
663+
commitId string
664+
localVarOptionals map[string]interface{}
665+
}
666+
tests := []struct {
667+
name string
668+
fields fields
669+
args args
670+
want *APIResponse
671+
wantErr, integrationTest bool
672+
}{
673+
{"networkErrorContextExceeded", fields{client: generateConfigFake()}, args{}, &APIResponse{Message: "Post https://stash.domain.com/rest/api/1.0/projects//repos//commits//comments: context canceled"}, true, false},
674+
}
675+
for _, tt := range tests {
676+
if tt.integrationTest != runIntegrationTests {
677+
continue
678+
}
679+
t.Run(tt.name, func(t *testing.T) {
680+
a := &DefaultApiService{
681+
client: tt.fields.client,
682+
}
683+
got, err := a.CreateComment(tt.args.projectKey, tt.args.repositorySlug, tt.args.commitId, tt.args.localVarOptionals)
684+
if (err != nil) != tt.wantErr {
685+
t.Errorf("DefaultApiService.CreateComment() error = %v, wantErr %v", err, tt.wantErr)
686+
return
687+
}
688+
if !reflect.DeepEqual(got, tt.want) {
689+
t.Errorf("DefaultApiService.CreateComment() = %v, want %v", got, tt.want)
690+
}
691+
})
692+
}
693+
}
694+
695+
func TestDefaultApiService_CreateCommentWithComment(t *testing.T) {
657696
type fields struct {
658697
client *APIClient
659698
}
@@ -700,16 +739,16 @@ func TestDefaultApiService_CreateComment(t *testing.T) {
700739
a := &DefaultApiService{
701740
client: tt.fields.client,
702741
}
703-
got, err := a.CreateComment(tt.args.projectKey, tt.args.repositorySlug, tt.args.commitId, tt.args.comment, tt.args.localVarOptionals)
742+
got, err := a.CreateCommentWithComment(tt.args.projectKey, tt.args.repositorySlug, tt.args.commitId, tt.args.comment, tt.args.localVarOptionals)
704743
if (err != nil) != tt.wantErr {
705-
t.Errorf("DefaultApiService.CreateComment() error = %v, wantErr %v", err, tt.wantErr)
744+
t.Errorf("DefaultApiService.CreateCommentWithComment() error = %v, wantErr %v", err, tt.wantErr)
706745
return
707746
}
708747
if got != nil {
709748
got.Response = nil
710749
}
711750
if !reflect.DeepEqual(got, tt.want) {
712-
t.Errorf("DefaultApiService.CreateComment() = %v, want %v", got, tt.want)
751+
t.Errorf("DefaultApiService.CreateCommentWithComment() = %v, want %v", got, tt.want)
713752
}
714753
})
715754
}

0 commit comments

Comments
 (0)