From 830586d242216e64fcd16e65cc83db9d54d63dc0 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Thu, 23 Sep 2021 07:50:50 +0800 Subject: test(cli): align unit test permissions with runtime test permissions (#12189) --- cli/tests/unit/read_dir_test.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'cli/tests/unit/read_dir_test.ts') diff --git a/cli/tests/unit/read_dir_test.ts b/cli/tests/unit/read_dir_test.ts index 49f899feb..ca900153a 100644 --- a/cli/tests/unit/read_dir_test.ts +++ b/cli/tests/unit/read_dir_test.ts @@ -21,37 +21,37 @@ function assertSameContent(files: Deno.DirEntry[]) { assertEquals(counter, 1); } -unitTest({ perms: { read: true } }, function readDirSyncSuccess() { +unitTest({ permissions: { read: true } }, function readDirSyncSuccess() { const files = [...Deno.readDirSync("cli/tests/testdata")]; assertSameContent(files); }); -unitTest({ perms: { read: true } }, function readDirSyncWithUrl() { +unitTest({ permissions: { read: true } }, function readDirSyncWithUrl() { const files = [ ...Deno.readDirSync(pathToAbsoluteFileUrl("cli/tests/testdata")), ]; assertSameContent(files); }); -unitTest({ perms: { read: false } }, function readDirSyncPerm() { +unitTest({ permissions: { read: false } }, function readDirSyncPerm() { assertThrows(() => { Deno.readDirSync("tests/"); }, Deno.errors.PermissionDenied); }); -unitTest({ perms: { read: true } }, function readDirSyncNotDir() { +unitTest({ permissions: { read: true } }, function readDirSyncNotDir() { assertThrows(() => { Deno.readDirSync("cli/tests/testdata/fixture.json"); }, Error); }); -unitTest({ perms: { read: true } }, function readDirSyncNotFound() { +unitTest({ permissions: { read: true } }, function readDirSyncNotFound() { assertThrows(() => { Deno.readDirSync("bad_dir_name"); }, Deno.errors.NotFound); }); -unitTest({ perms: { read: true } }, async function readDirSuccess() { +unitTest({ permissions: { read: true } }, async function readDirSuccess() { const files = []; for await (const dirEntry of Deno.readDir("cli/tests/testdata")) { files.push(dirEntry); @@ -59,7 +59,7 @@ unitTest({ perms: { read: true } }, async function readDirSuccess() { assertSameContent(files); }); -unitTest({ perms: { read: true } }, async function readDirWithUrl() { +unitTest({ permissions: { read: true } }, async function readDirWithUrl() { const files = []; for await ( const dirEntry of Deno.readDir(pathToAbsoluteFileUrl("cli/tests/testdata")) @@ -69,14 +69,14 @@ unitTest({ perms: { read: true } }, async function readDirWithUrl() { assertSameContent(files); }); -unitTest({ perms: { read: false } }, async function readDirPerm() { +unitTest({ permissions: { read: false } }, async function readDirPerm() { await assertRejects(async () => { await Deno.readDir("tests/")[Symbol.asyncIterator]().next(); }, Deno.errors.PermissionDenied); }); unitTest( - { perms: { read: true }, ignore: Deno.build.os == "windows" }, + { permissions: { read: true }, ignore: Deno.build.os == "windows" }, async function readDirDevFd(): Promise< void > { @@ -87,7 +87,7 @@ unitTest( ); unitTest( - { perms: { read: true }, ignore: Deno.build.os == "windows" }, + { permissions: { read: true }, ignore: Deno.build.os == "windows" }, function readDirDevFdSync() { for (const _ of Deno.readDirSync("/dev/fd")) { // We don't actually care whats in here; just that we don't panic on non regular file entries -- cgit v1.2.3