refactor(cli/tests/unit) to use assertThrows (#6459)

This commit is contained in:
Casper Beyer 2020-06-25 06:57:08 +08:00 committed by GitHub
parent 6bbe52fba3
commit 87f8f99c49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 404 additions and 913 deletions

View file

@ -43,32 +43,22 @@ unitTest(
unitTest(
{ perms: { read: false, write: true } },
function renameSyncReadPerm(): void {
let err;
try {
assertThrows(() => {
const oldpath = "/oldbaddir";
const newpath = "/newbaddir";
Deno.renameSync(oldpath, newpath);
} catch (e) {
err = e;
}
assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied");
}, Deno.errors.PermissionDenied);
}
);
unitTest(
{ perms: { read: true, write: false } },
function renameSyncWritePerm(): void {
let err;
try {
assertThrows(() => {
const oldpath = "/oldbaddir";
const newpath = "/newbaddir";
Deno.renameSync(oldpath, newpath);
} catch (e) {
err = e;
}
assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied");
}, Deno.errors.PermissionDenied);
}
);