Skip to content

Commit 15f2a16

Browse files
authored
Merge pull request #57 from danilopopeye/feature/implement-AddUserToGroups-parameters
add parameters to `AddUserToGroups` method
2 parents ae4ad57 + 90ff150 commit 15f2a16

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

default_api.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,19 @@ func (a *DefaultApiService) AddUserToGroup() (*APIResponse, error) {
128128
Add a user to one or more groups. <p> The authenticated user must have the <strong>ADMIN</strong> permission to call this resource.
129129

130130
@return */
131-
func (a *DefaultApiService) AddUserToGroups() (*APIResponse, error) {
131+
func (a *DefaultApiService) AddUserToGroups(name string, groups []string) (*APIResponse, error) {
132132
var (
133133
localVarHTTPMethod = strings.ToUpper("Post")
134134
localVarPostBody interface{}
135135
localVarFileName string
136136
localVarFileBytes []byte
137137
)
138138

139+
localVarPostBody = map[string]interface{}{
140+
"user": name,
141+
"groups": groups,
142+
}
143+
139144
// create path and map variables
140145
localVarPath := a.client.cfg.BasePath + "/api/1.0/admin/users/add-groups"
141146

@@ -175,7 +180,7 @@ func (a *DefaultApiService) AddUserToGroups() (*APIResponse, error) {
175180
return NewAPIResponseWithError(localVarHTTPResponse, bodyBytes, reportError("Status: %v, Body: %s", localVarHTTPResponse.Status, bodyBytes))
176181
}
177182

178-
return NewBitbucketAPIResponse(localVarHTTPResponse)
183+
return NewAPIResponse(localVarHTTPResponse), nil
179184
}
180185

181186
/* DefaultApiService

default_api_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ func TestDefaultApiService_AddUserToGroups(t *testing.T) {
124124
client *APIClient
125125
}
126126
type args struct {
127-
ctx context.Context
127+
name string
128+
groups []string
128129
}
129130
tests := []struct {
130131
name string
@@ -133,7 +134,7 @@ func TestDefaultApiService_AddUserToGroups(t *testing.T) {
133134
want *APIResponse
134135
wantErr, integrationTest bool
135136
}{
136-
{"networkErrorContextExceeded", fields{client: generateConfigFake()}, args{ctx: context.Background()}, &APIResponse{Message: "Post https://stash.domain.com/rest/api/1.0/admin/users/add-groups: context canceled"}, true, false},
137+
{"networkErrorContextExceeded", fields{client: generateConfigFake()}, args{name: "user", groups: []string{"group"}}, &APIResponse{Message: "Post https://stash.domain.com/rest/api/1.0/admin/users/add-groups: context canceled"}, true, false},
137138
}
138139
for _, tt := range tests {
139140
if tt.integrationTest != runIntegrationTests {
@@ -143,7 +144,7 @@ func TestDefaultApiService_AddUserToGroups(t *testing.T) {
143144
a := &DefaultApiService{
144145
client: tt.fields.client,
145146
}
146-
got, err := a.AddUserToGroups()
147+
got, err := a.AddUserToGroups(tt.args.name, tt.args.groups)
147148
if (err != nil) != tt.wantErr {
148149
t.Errorf("DefaultApiService.AddUserToGroups() error = %v, wantErr %v", err, tt.wantErr)
149150
return

0 commit comments

Comments
 (0)