[ARVADOS-WORKBENCH2] created: 1.4.1-161-g75ba9a3a

Git user git at public.arvados.org
Tue Dec 10 21:45:16 UTC 2019


        at  75ba9a3ad91766f21d7edf9f7bfc05226b2c0144 (commit)


commit 75ba9a3ad91766f21d7edf9f7bfc05226b2c0144
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date:   Tue Dec 10 18:44:33 2019 -0300

    15921: Updates tests to not expect trailing slashes on API calls.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>

diff --git a/src/services/common-service/common-resource-service.test.ts b/src/services/common-service/common-resource-service.test.ts
index a6a8b9d0..41a584fd 100644
--- a/src/services/common-service/common-resource-service.test.ts
+++ b/src/services/common-service/common-resource-service.test.ts
@@ -32,7 +32,7 @@ describe("CommonResourceService", () => {
 
     it("#create", async () => {
         axiosMock
-            .onPost("/resource/")
+            .onPost("/resource")
             .reply(200, { owner_uuid: "ownerUuidValue" });
 
         const commonResourceService = new CommonResourceService(axiosInstance, "resource", actions);
@@ -44,7 +44,7 @@ describe("CommonResourceService", () => {
         axiosInstance.post = jest.fn(() => Promise.resolve({data: {}}));
         const commonResourceService = new CommonResourceService(axiosInstance, "resource", actions);
         await commonResourceService.create({ ownerUuid: "ownerUuidValue" });
-        expect(axiosInstance.post).toHaveBeenCalledWith("/resource/", {owner_uuid: "ownerUuidValue"});
+        expect(axiosInstance.post).toHaveBeenCalledWith("/resource", {owner_uuid: "ownerUuidValue"});
     });
 
     it("#delete", async () => {
@@ -80,7 +80,7 @@ describe("CommonResourceService", () => {
 
     it("#list", async () => {
         axiosMock
-            .onGet("/resource/")
+            .onGet("/resource")
             .reply(200, {
                 kind: "kind",
                 offset: 2,
diff --git a/src/services/project-service/project-service.test.ts b/src/services/project-service/project-service.test.ts
index 90523606..aac04d96 100644
--- a/src/services/project-service/project-service.test.ts
+++ b/src/services/project-service/project-service.test.ts
@@ -18,7 +18,7 @@ describe("CommonResourceService", () => {
         axiosInstance.post = jest.fn(() => Promise.resolve({ data: {} }));
         const projectService = new ProjectService(axiosInstance, actions);
         const resource = await projectService.create({ name: "nameValue" });
-        expect(axiosInstance.post).toHaveBeenCalledWith("/groups/", {
+        expect(axiosInstance.post).toHaveBeenCalledWith("/groups", {
             name: "nameValue",
             group_class: "project"
         });
@@ -28,7 +28,7 @@ describe("CommonResourceService", () => {
         axiosInstance.get = jest.fn(() => Promise.resolve({ data: {} }));
         const projectService = new ProjectService(axiosInstance, actions);
         const resource = await projectService.list();
-        expect(axiosInstance.get).toHaveBeenCalledWith("/groups/", {
+        expect(axiosInstance.get).toHaveBeenCalledWith("/groups", {
             params: {
                 filters: "[" + new FilterBuilder()
                     .addEqual("groupClass", "project")

commit 4208a74b360bc040b9d9179fdbb3b5de5ad23ee5
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date:   Tue Dec 10 18:43:48 2019 -0300

    15921: Avoids adding a trailing slash to every resourceType.
    
    Updates API calls adding slashes where really needed.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>

diff --git a/src/services/common-service/common-service.ts b/src/services/common-service/common-service.ts
index 212f2f4d..1c1e0a56 100644
--- a/src/services/common-service/common-service.ts
+++ b/src/services/common-service/common-service.ts
@@ -38,7 +38,7 @@ export class CommonService<T> {
 
     constructor(serverApi: AxiosInstance, resourceType: string, actions: ApiActions) {
         this.serverApi = serverApi;
-        this.resourceType = '/' + resourceType + '/';
+        this.resourceType = '/' + resourceType;
         this.actions = actions;
     }
 
@@ -93,7 +93,7 @@ export class CommonService<T> {
     delete(uuid: string): Promise<T> {
         return CommonService.defaultResponse(
             this.serverApi
-                .delete(this.resourceType + uuid),
+                .delete(this.resourceType + '/' + uuid),
             this.actions
         );
     }
@@ -101,7 +101,7 @@ export class CommonService<T> {
     get(uuid: string) {
         return CommonService.defaultResponse(
             this.serverApi
-                .get<T>(this.resourceType + uuid),
+                .get<T>(this.resourceType + '/' + uuid),
             this.actions
         );
     }
@@ -125,7 +125,7 @@ export class CommonService<T> {
     update(uuid: string, data: Partial<T>) {
         return CommonService.defaultResponse(
             this.serverApi
-                .put<T>(this.resourceType + uuid, data && CommonService.mapKeys(_.snakeCase)(data)),
+                .put<T>(this.resourceType + '/' + uuid, data && CommonService.mapKeys(_.snakeCase)(data)),
             this.actions
         );
     }
diff --git a/src/services/common-service/trashable-resource-service.ts b/src/services/common-service/trashable-resource-service.ts
index 633b2fbd..5746bffb 100644
--- a/src/services/common-service/trashable-resource-service.ts
+++ b/src/services/common-service/trashable-resource-service.ts
@@ -17,7 +17,7 @@ export class TrashableResourceService<T extends TrashableResource> extends Commo
     trash(uuid: string): Promise<T> {
         return CommonResourceService.defaultResponse(
             this.serverApi
-                .post(this.resourceType + `${uuid}/trash`),
+                .post(this.resourceType + `/${uuid}/trash`),
             this.actions
         );
     }
@@ -28,7 +28,7 @@ export class TrashableResourceService<T extends TrashableResource> extends Commo
         };
         return CommonResourceService.defaultResponse(
             this.serverApi
-                .post(this.resourceType + `${uuid}/untrash`, {
+                .post(this.resourceType + `/${uuid}/untrash`, {
                     params: CommonResourceService.mapKeys(_.snakeCase)(params)
                 }),
             this.actions
diff --git a/src/services/groups-service/groups-service.ts b/src/services/groups-service/groups-service.ts
index 691ab8f7..281aa921 100644
--- a/src/services/groups-service/groups-service.ts
+++ b/src/services/groups-service/groups-service.ts
@@ -46,8 +46,7 @@ export class GroupsService<T extends GroupResource = GroupResource> extends Tras
             filters: filters ? `[${filters}]` : undefined,
             order: order ? order : undefined
         };
-
-        const pathUrl = uuid ? `${uuid}/contents` : 'contents';
+        const pathUrl = uuid ? `/${uuid}/contents` : '/contents';
 
         const cfg: AxiosRequestConfig = { params: CommonResourceService.mapKeys(_.snakeCase)(params) };
         if (session) {
@@ -65,7 +64,7 @@ export class GroupsService<T extends GroupResource = GroupResource> extends Tras
     shared(params: SharedArguments = {}): Promise<ListResults<GroupContentsResource>> {
         return CommonResourceService.defaultResponse(
             this.serverApi
-                .get(this.resourceType + 'shared', { params }),
+                .get(this.resourceType + '/shared', { params }),
             this.actions
         );
     }
diff --git a/src/services/user-service/user-service.ts b/src/services/user-service/user-service.ts
index ddb9a364..d8c7fe3d 100644
--- a/src/services/user-service/user-service.ts
+++ b/src/services/user-service/user-service.ts
@@ -15,7 +15,7 @@ export class UserService extends CommonResourceService<UserResource> {
     activate(uuid: string) {
         return CommonResourceService.defaultResponse(
             this.serverApi
-                .post(this.resourceType + `${uuid}/activate`),
+                .post(this.resourceType + `/${uuid}/activate`),
             this.actions
         );
     }
@@ -23,7 +23,7 @@ export class UserService extends CommonResourceService<UserResource> {
     unsetup(uuid: string) {
         return CommonResourceService.defaultResponse(
             this.serverApi
-                .post(this.resourceType + uuid + '/unsetup'),
+                .post(this.resourceType + `/${uuid}/unsetup`),
             this.actions
         );
     }

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list