From c65fa7ee2eeeb52a60a3230ce2a465d43541bfad Mon Sep 17 00:00:00 2001 From: Ansu Kumari Date: Mon, 29 Apr 2024 15:16:24 +0200 Subject: [PATCH 1/2] Return instance when instance already booted. Signed-off-by: An K --- src/VaultClient.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/VaultClient.js b/src/VaultClient.js index 2a46a2d..b5b1009 100644 --- a/src/VaultClient.js +++ b/src/VaultClient.js @@ -63,11 +63,8 @@ class VaultClient { let instance = vaultInstances[name]; if (instance === undefined) { vaultInstances[name] = instance = new VaultClient(options); - - return instance; } - - throw new errors.InvalidArgumentsError('Instance with such name already booted'); + return instance; } /** From 147eb2d099f88a93f77099b9f4bad8ee252265af Mon Sep 17 00:00:00 2001 From: Ansu Kumari Date: Mon, 29 Apr 2024 15:22:06 +0200 Subject: [PATCH 2/2] Test to check if boot function returns instance when instance already booted. Signed-off-by: An K --- test/unit.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit.test.js b/test/unit.test.js index 904c1a7..f5ea20a 100644 --- a/test/unit.test.js +++ b/test/unit.test.js @@ -27,7 +27,7 @@ describe('Unit tests', function () { expect(VaultClient.get('tst')).to.equal(i); - expect(() => VaultClient.boot('tst', bootOpts)).to.throw(VaultErr.InvalidArgumentsError, 'Instance with such name already booted'); + expect(VaultClient.boot('tst')).to.equal(i); const i2 = VaultClient.boot('tst2', bootOpts);