From f9557a4ff6b73a4af37e713bb6b2294253c7b230 Mon Sep 17 00:00:00 2001 From: dubiousjim Date: Mon, 16 Mar 2020 15:02:41 -0400 Subject: Add mode option to open/create (#4289) --- cli/js/tests/files_test.ts | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'cli/js/tests/files_test.ts') diff --git a/cli/js/tests/files_test.ts b/cli/js/tests/files_test.ts index 29e2812d4..b087d7398 100644 --- a/cli/js/tests/files_test.ts +++ b/cli/js/tests/files_test.ts @@ -74,6 +74,44 @@ unitTest(async function readerToAsyncIterator(): Promise { assertEquals(totalSize, 12); }); +unitTest( + { + perms: { read: true, write: true } + }, + function openSyncMode(): void { + const path = Deno.makeTempDirSync() + "/test_openSync.txt"; + const file = Deno.openSync(path, { + write: true, + createNew: true, + mode: 0o626 + }); + file.close(); + const pathInfo = Deno.statSync(path); + if (Deno.build.os !== "win") { + assertEquals(pathInfo.mode! & 0o777, 0o626 & ~Deno.umask()); + } + } +); + +unitTest( + { + perms: { read: true, write: true } + }, + async function openMode(): Promise { + const path = (await Deno.makeTempDir()) + "/test_open.txt"; + const file = await Deno.open(path, { + write: true, + createNew: true, + mode: 0o626 + }); + file.close(); + const pathInfo = Deno.statSync(path); + if (Deno.build.os !== "win") { + assertEquals(pathInfo.mode! & 0o777, 0o626 & ~Deno.umask()); + } + } +); + unitTest( { perms: { write: false } }, async function writePermFailure(): Promise { -- cgit v1.2.3