Browse Source

Clean code

tumao 3 years ago
parent
commit
60e4175c36

+ 0 - 12
express/src/__tests__/crons/crons.service.test.ts

@@ -144,18 +144,6 @@ describe('test crons service', () => {
 
   test('test getCollections error', async () => {
     // reset setup to trigger error
-    // jest.mock('../../collections/collections.service', () => {
-    //   return {
-    //     CollectionService: jest.fn().mockImplementation((milvusService) => ({
-    //       getAllCollections: () => {
-    //         throw new Error('error');
-    //       },
-    //     })),
-    //   };
-    // });
-
-    // await setup();
-
     const newCollectionService = new CollectionsService(milvusService);
     const newSchedulerRegistry = new SchedulerRegistry([]);
     newCollectionService.getAllCollections = () => {

+ 4 - 1
express/src/crons/crons.service.ts

@@ -47,7 +47,10 @@ export class CronsService {
         //   type: WS_EVENTS_TYPE.STOP,
         // });
         const cronJobEntity = this.schedulerRegistry.getCronJob(name);
-        cronJobEntity && cronJobEntity.stop();
+        if (cronJobEntity) {
+          cronJobEntity.stop();
+        }
+
         throw new Error(error);
       }
     };