Skip to content

Commit

Permalink
Add new for TSError and use reject.toThrow
Browse files Browse the repository at this point in the history
  • Loading branch information
godber committed Jan 28, 2021
1 parent 11836b6 commit 6f98a7f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ class K8s {
} if (jobs.items.length === 0) {
const msg = `Teraslice ${objType} matching the following selector was not found: ${selector} (retriable)`;
this.logger.warn(msg);
throw TSError(msg, { retryable: true });
throw new TSError(msg, { retryable: true });
} else {
throw TSError(`Unexpected number of Teraslice ${objType}s matching the following selector: ${selector}`, {
throw new TSError(`Unexpected number of Teraslice ${objType}s matching the following selector: ${selector}`, {
retryable: true
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,8 @@ describe('k8s', () => {
.query({ labelSelector: 'app=teraslice' })
.reply(200, { items: [] });

try {
await k8s.nonEmptyList('app=teraslice', 'jobs');
} catch (error) {
expect(error).toEqual(
Error('Teraslice jobs matching the following selector was not found: app=teraslice (retriable)')
);
}
await expect(k8s.nonEmptyList('app=teraslice', 'jobs'))
.rejects.toThrowError('Teraslice jobs matching the following selector was not found: app=teraslice (retriable)');
});
});

Expand Down

0 comments on commit 6f98a7f

Please sign in to comment.