summaryrefslogtreecommitdiff
path: root/cli/js/tests/files_test.ts
diff options
context:
space:
mode:
authordubiousjim <dubiousjim@gmail.com>2020-03-16 15:02:41 -0400
committerGitHub <noreply@github.com>2020-03-16 15:02:41 -0400
commitf9557a4ff6b73a4af37e713bb6b2294253c7b230 (patch)
tree0a4e05e6fb709e1c4ebb4bc21c2b50685049e6f4 /cli/js/tests/files_test.ts
parent8077ade7413db72572b8685c883f078335e0561b (diff)
Add mode option to open/create (#4289)
Diffstat (limited to 'cli/js/tests/files_test.ts')
-rw-r--r--cli/js/tests/files_test.ts38
1 files changed, 38 insertions, 0 deletions
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
@@ -75,6 +75,44 @@ unitTest(async function readerToAsyncIterator(): Promise<void> {
});
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<void> {
+ 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<void> {
const filename = "tests/hello.txt";