summaryrefslogtreecommitdiff
path: root/cli/tests/unit/chmod_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/unit/chmod_test.ts')
-rw-r--r--cli/tests/unit/chmod_test.ts42
1 files changed, 15 insertions, 27 deletions
diff --git a/cli/tests/unit/chmod_test.ts b/cli/tests/unit/chmod_test.ts
index 02a5fb22e..5a2afd507 100644
--- a/cli/tests/unit/chmod_test.ts
+++ b/cli/tests/unit/chmod_test.ts
@@ -1,5 +1,11 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import { unitTest, assert, assertEquals } from "./test_util.ts";
+import {
+ unitTest,
+ assert,
+ assertEquals,
+ assertThrows,
+ assertThrowsAsync,
+} from "./test_util.ts";
unitTest(
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
@@ -70,25 +76,16 @@ unitTest(
);
unitTest({ perms: { write: true } }, function chmodSyncFailure(): void {
- let err;
- try {
+ assertThrows(() => {
const filename = "/badfile.txt";
Deno.chmodSync(filename, 0o777);
- } catch (e) {
- err = e;
- }
- assert(err instanceof Deno.errors.NotFound);
+ }, Deno.errors.NotFound);
});
unitTest({ perms: { write: false } }, function chmodSyncPerm(): void {
- let err;
- try {
+ assertThrows(() => {
Deno.chmodSync("/somefile.txt", 0o777);
- } catch (e) {
- err = e;
- }
- assert(err instanceof Deno.errors.PermissionDenied);
- assertEquals(err.name, "PermissionDenied");
+ }, Deno.errors.PermissionDenied);
});
unitTest(
@@ -163,25 +160,16 @@ unitTest(
unitTest({ perms: { write: true } }, async function chmodFailure(): Promise<
void
> {
- let err;
- try {
+ await assertThrowsAsync(async () => {
const filename = "/badfile.txt";
await Deno.chmod(filename, 0o777);
- } catch (e) {
- err = e;
- }
- assert(err instanceof Deno.errors.NotFound);
+ }, Deno.errors.NotFound);
});
unitTest({ perms: { write: false } }, async function chmodPerm(): Promise<
void
> {
- let err;
- try {
+ await assertThrowsAsync(async () => {
await Deno.chmod("/somefile.txt", 0o777);
- } catch (e) {
- err = e;
- }
- assert(err instanceof Deno.errors.PermissionDenied);
- assertEquals(err.name, "PermissionDenied");
+ }, Deno.errors.PermissionDenied);
});