Skip to content

Commit 503e2f6

Browse files
committed
Add test for repeated wrapApiConfigurationError
1 parent 260cb2a commit 503e2f6

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎src/api-client.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,23 @@ test("wrapApiConfigurationError wraps enablement errors", async (t) => {
204204
}
205205
});
206206

207+
test("wrapApiConfigurationError doesn't double-wrap errors", async (t) => {
208+
// This test checks that errors don't get wrapped a second time if `wrapApiConfigurationError`
209+
// is called on an error that was already wrapped by a previous call to `wrapApiConfigurationError`.
210+
// Start by calling `wrapApiConfigurationError` on an unwrapped error that should be wrapped:
211+
const unwrappedError = new util.HTTPError("commit not found", 404);
212+
const wrappedError = api.wrapApiConfigurationError(unwrappedError);
213+
214+
// Sanity-check that it was wrapped, as expected.
215+
t.deepEqual(
216+
wrappedError,
217+
new util.ConfigurationError(unwrappedError.message),
218+
);
219+
220+
// The result of the second call should be exactly `wrappedError`:
221+
t.is(api.wrapApiConfigurationError(wrappedError), wrappedError);
222+
});
223+
207224
test("getRegistryProxy - returns undefined if the proxy is not configured", async (t) => {
208225
const target = callee(api.getRegistryProxy).withArgs();
209226

0 commit comments

Comments
 (0)