Skip to content

Commit

Permalink
[KeyVault-Keys] The service started sending different error messages (A…
Browse files Browse the repository at this point in the history
…zure#8830)

* [KeyVault-Keys] The service started sending different error messages

* restoring the master recordings

* Suggestion from Ramya: comparing the status code

I also added a line comparing the RestError "code" since that seemed a
bit more specific to the client, perhaps more useful to catch the
specific error.
  • Loading branch information
sadasant authored May 11, 2020
1 parent 84cbf47 commit 0bb0ec7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
13 changes: 6 additions & 7 deletions sdk/keyvault/keyvault-keys/test/CRUD.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ describe("Keys client - create, read, update and delete operations", () => {
throw Error("Expecting an error but not catching one.");
} catch (e) {
if (e instanceof RestError) {
assert.equal(e.message, `Key not found: ${keyName}`);
assert.equal(e.code, "KeyNotFound");
assert.equal(e.statusCode, 404);
} else {
throw e;
}
Expand Down Expand Up @@ -271,7 +272,8 @@ describe("Keys client - create, read, update and delete operations", () => {
throw Error("Expecting an error but not catching one.");
} catch (e) {
if (e instanceof RestError) {
assert.equal(e.message, `Key not found: ${keyName}`);
assert.equal(e.code, "KeyNotFound");
assert.equal(e.statusCode, 404);
} else {
throw e;
}
Expand Down Expand Up @@ -340,11 +342,8 @@ describe("Keys client - create, read, update and delete operations", () => {
} catch (e) {
error = e;
}
assert.equal(
error.message,
`Key not found: ${keyName}`,
"Unexpected key name in result from getKey()."
);
assert.equal(error.code, "KeyNotFound");
assert.equal(error.statusCode, 404);
});

it("can purge a deleted key", async function() {
Expand Down
6 changes: 4 additions & 2 deletions sdk/keyvault/keyvault-keys/test/recoverBackupRestore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ describe("Keys client - restore keys and recover backups", () => {
} catch (e) {
error = e;
}
assert.equal(error.message, `Key not found: ${keyName}`);
assert.equal(error.code, "KeyNotFound");
assert.equal(error.statusCode, 404);
});

it("can generate a backup of a key", async function() {
Expand Down Expand Up @@ -95,7 +96,8 @@ describe("Keys client - restore keys and recover backups", () => {
} catch (e) {
error = e;
}
assert.equal(error.message, `Key not found: ${keyName}`);
assert.equal(error.code, "KeyNotFound");
assert.equal(error.statusCode, 404);
});

if (isRecordMode() || isPlaybackMode()) {
Expand Down

0 comments on commit 0bb0ec7

Please sign in to comment.