From: Jérôme Benoit Date: Sun, 3 Sep 2023 21:55:56 +0000 (+0200) Subject: refactor: cleanup exit codes X-Git-Tag: v1.2.21~33 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a51a4ead39e6926f7f63c6eb6871c59fe9b555b7;p=e-mobility-charging-stations-simulator.git refactor: cleanup exit codes Signed-off-by: Jérôme Benoit --- 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);