[ARVADOS-WORKBENCH2] updated: 2.1.0-114-gd50bc0ac

Git user git at public.arvados.org
Fri Jan 8 16:38:22 UTC 2021


Summary of changes:
 .../collection-service/collection-service.test.ts  | 69 ++++++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 src/services/collection-service/collection-service.test.ts

       via  d50bc0acaab286ec7c639c2bb52280a2e3099a67 (commit)
      from  d5db24f8cfa26d546596b99e644e37c72b6b1fae (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit d50bc0acaab286ec7c639c2bb52280a2e3099a67
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date:   Fri Jan 8 17:37:32 2021 +0100

    17016: Added more unit tests
    
    Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>

diff --git a/src/services/collection-service/collection-service.test.ts b/src/services/collection-service/collection-service.test.ts
new file mode 100644
index 00000000..19ac7490
--- /dev/null
+++ b/src/services/collection-service/collection-service.test.ts
@@ -0,0 +1,69 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { AxiosInstance } from 'axios';
+import { WebDAV } from '~/common/webdav';
+import { ApiActions } from '../api/api-actions';
+import { AuthService } from '../auth-service/auth-service';
+import { CollectionService } from './collection-service';
+
+describe('collection-service', () => {
+    let collectionService: CollectionService;
+    let serverApi;
+    let webdavClient: any;
+    let authService;
+    let actions;
+
+    beforeEach(() => {
+        serverApi = {} as AxiosInstance;
+        webdavClient = {
+            delete: jest.fn(),
+        } as any;
+        authService = {} as AuthService;
+        actions = {} as ApiActions;
+        collectionService = new CollectionService(serverApi, webdavClient, authService, actions);
+    });
+
+    describe('deleteFiles', () => {
+        it('should remove no files', async () => {
+            // given
+            const filePaths: string[] = [];
+            const collectionUUID = '';
+
+            // when
+            await collectionService.deleteFiles(collectionUUID, filePaths);
+
+            // then
+            expect(webdavClient.delete).not.toHaveBeenCalled();
+        });
+
+        it('should remove only root files', async () => {
+            // given
+            const filePaths: string[] = ['/root/1', '/root/1/100', '/root/1/100/test.txt', '/root/2', '/root/2/200', '/root/3/300/test.txt'];
+            const collectionUUID = '';
+
+            // when
+            await collectionService.deleteFiles(collectionUUID, filePaths);
+
+            // then
+            expect(webdavClient.delete).toHaveBeenCalledTimes(3);
+            expect(webdavClient.delete).toHaveBeenCalledWith("c=/root/3/300/test.txt");
+            expect(webdavClient.delete).toHaveBeenCalledWith("c=/root/2");
+            expect(webdavClient.delete).toHaveBeenCalledWith("c=/root/1");
+        });
+
+        it('should remove files with uuid prefix', async () => {
+            // given
+            const filePaths: string[] = ['/root/1'];
+            const collectionUUID = 'zzzzz-tpzed-5o5tg0l9a57gxxx';
+
+            // when
+            await collectionService.deleteFiles(collectionUUID, filePaths);
+
+            // then
+            expect(webdavClient.delete).toHaveBeenCalledTimes(1);
+            expect(webdavClient.delete).toHaveBeenCalledWith("c=zzzzz-tpzed-5o5tg0l9a57gxxx/root/1");
+        });
+    });
+});
\ No newline at end of file

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list