Repository: ctreminiom/go-atlassian
Pull request #106 (2022-02-05 02:04:44)

:bug: Fixed the Confluence.Space.Gets params


Patch:
diff --git a/confluence/space.go b/confluence/space.go
index 6d68cf5..fa38beb 100644
--- a/confluence/space.go
+++ b/confluence/space.go
@@ -26,7 +26,10 @@ func (s *SpaceService) Gets(ctx context.Context, options *model.GetSpacesOptionS
 	if options != nil {
 
 		if len(options.SpaceKeys) != 0 {
-			query.Add("spaceKey", strings.Join(options.SpaceKeys, ","))
+
+			for _, key := range options.SpaceKeys {
+				query.Add("spaceKey", key)
+			}
 		}
 
 		if len(options.SpaceIDs) != 0 {


Test patch:
diff --git a/confluence/space_test.go b/confluence/space_test.go
index 676dab2..790ec9f 100644
--- a/confluence/space_test.go
+++ b/confluence/space_test.go
@@ -39,7 +39,7 @@ func TestSpaceService_Gets(t *testing.T) {
 			maxResults:         50,
 			mockFile:           "./mocks/get-spaces.json",
 			wantHTTPMethod:     http.MethodGet,
-			endpoint:           "/wiki/rest/api/space?expand=operations&favorite=true&favouriteUserKey=DUMMY&label=label-09%2Clabel-02&limit=50&spaceId=1111&spaceId=2222&spaceId=3333&spaceKey=DUMMY%2CTEST&start=0&status=archived&type=global",
+			endpoint:           "/wiki/rest/api/space?expand=operations&favorite=true&favouriteUserKey=DUMMY&label=label-09%2Clabel-02&limit=50&spaceId=1111&spaceId=2222&spaceId=3333&spaceKey=DUMMY&spaceKey=TEST&start=0&status=archived&type=global",
 			context:            context.Background(),
 			wantHTTPCodeReturn: http.StatusOK,
 			wantErr:            false,
@@ -61,7 +61,7 @@ func TestSpaceService_Gets(t *testing.T) {
 			maxResults:         50,
 			mockFile:           "./mocks/get-spaces.json",
 			wantHTTPMethod:     http.MethodGet,
-			endpoint:           "/wiki/rest/api/space?expand=operations&favorite=true&favouriteUserKey=DUMMY&label=label-09%2Clabel-02&limit=50&spaceId=1111&spaceId=2222&spaceId=3333&spaceKey=DUMMY%2CTEST&start=0&status=archived&type=global",
+			endpoint:           "/wiki/rest/api/space?expand=operations&favorite=true&favouriteUserKey=DUMMY&label=label-09%2Clabel-02&limit=50&spaceId=1111&spaceId=2222&spaceId=3333&spaceKey=DUMMY&spaceKey=TEST&start=0&status=archived&type=global",
 			context:            nil,
 			wantHTTPCodeReturn: http.StatusOK,
 			wantErr:            true,
@@ -83,7 +83,7 @@ func TestSpaceService_Gets(t *testing.T) {
 			maxResults:         50,
 			mockFile:           "./mocks/get-spaces.json",
 			wantHTTPMethod:     http.MethodPut,
-			endpoint:           "/wiki/rest/api/space?expand=operations&favorite=true&favouriteUserKey=DUMMY&label=label-09%2Clabel-02&limit=50&spaceId=1111&spaceId=2222&spaceId=3333&spaceKey=DUMMY%2CTEST&start=0&status=archived&type=global",
+			endpoint:           "/wiki/rest/api/space?expand=operations&favorite=true&favouriteUserKey=DUMMY&label=label-09%2Clabel-02&limit=50&spaceId=1111&spaceId=2222&spaceId=3333&spaceKey=DUMMY&spaceKey=TEST&start=0&status=archived&type=global",
 			context:            context.Background(),
 			wantHTTPCodeReturn: http.StatusOK,
 			wantErr:            true,
@@ -105,7 +105,7 @@ func TestSpaceService_Gets(t *testing.T) {
 			maxResults:         50,
 			mockFile:           "./mocks/get-spaces.json",
 			wantHTTPMethod:     http.MethodGet,
-			endpoint:           "/wiki/rest/api/space?expand=operations&favorite=true&favouriteUserKey=DUMMY&label=label-09%2Clabel-02&limit=50&spaceId=1111&spaceId=2222&spaceId=3333&spaceKey=DUMMY%2CTEST&start=0&status=archived&type=global",
+			endpoint:           "/wiki/rest/api/space?expand=operations&favorite=true&favouriteUserKey=DUMMY&label=label-09%2Clabel-02&limit=50&spaceId=1111&spaceId=2222&spaceId=3333&spaceKey=DUMMY&spaceKey=TEST&start=0&status=archived&type=global",
 			context:            context.Background(),
 			wantHTTPCodeReturn: http.StatusBadRequest,
 			wantErr:            true,
@@ -127,7 +127,7 @@ func TestSpaceService_Gets(t *testing.T) {
 			maxResults:         50,
 			mockFile:           "./mocks/empty-json.json",
 			wantHTTPMethod:     http.MethodGet,
-			endpoint:           "/wiki/rest/api/space?expand=operations&favorite=true&favouriteUserKey=DUMMY&label=label-09%2Clabel-02&limit=50&spaceId=1111&spaceId=2222&spaceId=3333&spaceKey=DUMMY%2CTEST&start=0&status=archived&type=global",
+			endpoint:           "/wiki/rest/api/space?expand=operations&favorite=true&favouriteUserKey=DUMMY&label=label-09%2Clabel-02&limit=50&spaceId=1111&spaceId=2222&spaceId=3333&spaceKey=DUMMY&spaceKey=TEST&start=0&status=archived&type=global",
 			context:            context.Background(),
 			wantHTTPCodeReturn: http.StatusOK,
 			wantErr:            true,