diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2020-05-02 18:33:43 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-02 18:33:43 -0400 |
commit | bbbf9f299c284e24882927d34e13ffad1ed6093e (patch) | |
tree | 7ae4e1a565e4a1af992315c3719120826486068f /cli/js/tests | |
parent | 2872b362ff76273d897d75bb8a3ddd5510c182f4 (diff) |
Deno.chdir should require allow-read not allow-write (#5033)
Diffstat (limited to 'cli/js/tests')
-rw-r--r-- | cli/js/tests/dir_test.ts | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/cli/js/tests/dir_test.ts b/cli/js/tests/dir_test.ts index 09236fa22..3686471f1 100644 --- a/cli/js/tests/dir_test.ts +++ b/cli/js/tests/dir_test.ts @@ -5,20 +5,23 @@ unitTest(function dirCwdNotNull(): void { assert(Deno.cwd() != null); }); -unitTest({ perms: { write: true } }, function dirCwdChdirSuccess(): void { - const initialdir = Deno.cwd(); - const path = Deno.makeTempDirSync(); - Deno.chdir(path); - const current = Deno.cwd(); - if (Deno.build.os === "darwin") { - assertEquals(current, "/private" + path); - } else { - assertEquals(current, path); +unitTest( + { perms: { read: true, write: true } }, + function dirCwdChdirSuccess(): void { + const initialdir = Deno.cwd(); + const path = Deno.makeTempDirSync(); + Deno.chdir(path); + const current = Deno.cwd(); + if (Deno.build.os === "darwin") { + assertEquals(current, "/private" + path); + } else { + assertEquals(current, path); + } + Deno.chdir(initialdir); } - Deno.chdir(initialdir); -}); +); -unitTest({ perms: { write: true } }, function dirCwdError(): void { +unitTest({ perms: { read: true, write: true } }, function dirCwdError(): void { // excluding windows since it throws resource busy, while removeSync if (["linux", "darwin"].includes(Deno.build.os)) { const initialdir = Deno.cwd(); @@ -39,16 +42,19 @@ unitTest({ perms: { write: true } }, function dirCwdError(): void { } }); -unitTest({ perms: { write: true } }, function dirChdirError(): void { - const path = Deno.makeTempDirSync() + "test"; - try { - Deno.chdir(path); - throw Error("directory not available, should throw error"); - } catch (err) { - if (err instanceof Deno.errors.NotFound) { - assert(err.name === "NotFound"); - } else { - throw Error("raised different exception"); +unitTest( + { perms: { read: true, write: true } }, + function dirChdirError(): void { + const path = Deno.makeTempDirSync() + "test"; + try { + Deno.chdir(path); + throw Error("directory not available, should throw error"); + } catch (err) { + if (err instanceof Deno.errors.NotFound) { + assert(err.name === "NotFound"); + } else { + throw Error("raised different exception"); + } } } -}); +); |