From a51a4ead39e6926f7f63c6eb6871c59fe9b555b7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 3 Sep 2023 23:55:56 +0200 Subject: [PATCH] refactor: cleanup exit codes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/Bootstrap.ts | 6 ++++-- test/utils/Utils.test.ts | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 27f4a607..88c79f4b 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -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); }); }; diff --git a/test/utils/Utils.test.ts b/test/utils/Utils.test.ts index ab07ec81..1e0cff5a 100644 --- a/test/utils/Utils.test.ts +++ b/test/utils/Utils.test.ts @@ -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); -- 2.34.1