refactor: cleanup exit codes
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 3 Sep 2023 21:55:56 +0000 (23:55 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 3 Sep 2023 21:55:56 +0000 (23:55 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/Bootstrap.ts
test/utils/Utils.test.ts

index 27f4a6073c8c5159c1bfa2b134688e6d6027325a..88c79f4b3ac77b994bc8094a60e35c0b7fa1eae9 100644 (file)
@@ -45,8 +45,10 @@ import { type WorkerAbstract, WorkerFactory } from '../worker';
 const moduleName = 'Bootstrap';
 
 enum exitCodes {
+  succeeded = 0,
   missingChargingStationsConfiguration = 1,
   noChargingStationTemplates = 2,
+  gracefulShutdownError = 3,
 }
 
 export class Bootstrap extends EventEmitter {
@@ -389,11 +391,11 @@ export class Bootstrap extends EventEmitter {
     console.info(`${chalk.green('Graceful shutdown')}`);
     this.stop()
       .then(() => {
-        process.exit(0);
+        process.exit(exitCodes.succeeded);
       })
       .catch((error) => {
         console.error(chalk.red('Error while shutdowning charging stations simulator: '), error);
-        process.exit(1);
+        process.exit(exitCodes.gracefulShutdownError);
       });
   };
 
index ab07ec81d7668321010b4f5e6905f6709d8f22c7..1e0cff5a9d2a77ad7704e29d2387321aa32ee08c 100644 (file)
@@ -451,6 +451,7 @@ describe('Utils test suite', () => {
   });
 
   it('Verify min()', () => {
+    expect(min()).toBe(Infinity);
     expect(min(0, 1)).toBe(0);
     expect(min(1, 0)).toBe(0);
     expect(min(0, -1)).toBe(-1);
@@ -458,6 +459,7 @@ describe('Utils test suite', () => {
   });
 
   it('Verify max()', () => {
+    expect(max()).toBe(-Infinity);
     expect(max(0, 1)).toBe(1);
     expect(max(1, 0)).toBe(1);
     expect(max(0, -1)).toBe(0);