From b0afd6ec3cadb2a5c799d824a477ac95309adf2b Mon Sep 17 00:00:00 2001 From: Emmanuel Nyachoke Date: Thu, 31 Oct 2024 13:29:25 +0300 Subject: [PATCH] Fix unit test --- lib/container-to-consul.js | 3 ++- test/lib/container-to-consul.test.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/container-to-consul.js b/lib/container-to-consul.js index ba533c7..6631e00 100644 --- a/lib/container-to-consul.js +++ b/lib/container-to-consul.js @@ -44,7 +44,7 @@ class ContainertoConsul { // deregister containers that do not run .then(() => this.consul.kv.keys('docker/service-ids/') .catch(error => { - if (error.response.status && error.response.status === 404) { + if (error.response && error.response.status && error.response.status === 404) { return []; } throw error; @@ -74,6 +74,7 @@ class ContainertoConsul { .then(containers => this.registerContainers(containers)) .catch(error => { this.log.error(error); + throw error; }); } diff --git a/test/lib/container-to-consul.test.js b/test/lib/container-to-consul.test.js index cba3ec3..0ab8d7c 100644 --- a/test/lib/container-to-consul.test.js +++ b/test/lib/container-to-consul.test.js @@ -236,7 +236,7 @@ describe('container-to-consul', () => { it('should not fail if no docker/service-ids key is stored in consul', () => { var error = new Error('test'); - error.statusCode = 404; + error.response = {status: 404}; containertoConsul.consul.kv.keys.rejects(error);