Skip to content

Commit

Permalink
Fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
enyachoke committed Oct 31, 2024
1 parent b2f458b commit b0afd6e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/container-to-consul.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,6 +74,7 @@ class ContainertoConsul {
.then(containers => this.registerContainers(containers))
.catch(error => {
this.log.error(error);
throw error;
});
}

Expand Down
2 changes: 1 addition & 1 deletion test/lib/container-to-consul.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit b0afd6e

Please sign in to comment.