summaryrefslogtreecommitdiff
path: root/cli/tests/unit/chmod_test.ts
diff options
context:
space:
mode:
authorRiver <22485304+actual-size@users.noreply.github.com>2020-06-12 02:36:20 +1000
committerGitHub <noreply@github.com>2020-06-11 12:36:20 -0400
commit818a8010928cb8cef0b7043bd881c8cdce9b6efc (patch)
tree1502e74c9eb01901df8da118257d60d4f962b0e4 /cli/tests/unit/chmod_test.ts
parent813210d4337bf6e174f1da1f1a6c6fb9b073afa2 (diff)
feat: URL support in Deno filesystem methods (#5990)
Diffstat (limited to 'cli/tests/unit/chmod_test.ts')
-rw-r--r--cli/tests/unit/chmod_test.ts38
1 files changed, 38 insertions, 0 deletions
diff --git a/cli/tests/unit/chmod_test.ts b/cli/tests/unit/chmod_test.ts
index d0d17629d..02a5fb22e 100644
--- a/cli/tests/unit/chmod_test.ts
+++ b/cli/tests/unit/chmod_test.ts
@@ -18,6 +18,25 @@ unitTest(
}
);
+unitTest(
+ { ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
+ function chmodSyncUrl(): void {
+ const enc = new TextEncoder();
+ const data = enc.encode("Hello");
+ const tempDir = Deno.makeTempDirSync();
+ const fileUrl = new URL(`file://${tempDir}/test.txt`);
+ Deno.writeFileSync(fileUrl, data, { mode: 0o666 });
+
+ Deno.chmodSync(fileUrl, 0o777);
+
+ const fileInfo = Deno.statSync(fileUrl);
+ assert(fileInfo.mode);
+ assertEquals(fileInfo.mode & 0o777, 0o777);
+
+ Deno.removeSync(tempDir, { recursive: true });
+ }
+);
+
// Check symlink when not on windows
unitTest(
{
@@ -89,6 +108,25 @@ unitTest(
}
);
+unitTest(
+ { ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
+ async function chmodUrl(): Promise<void> {
+ const enc = new TextEncoder();
+ const data = enc.encode("Hello");
+ const tempDir = Deno.makeTempDirSync();
+ const fileUrl = new URL(`file://${tempDir}/test.txt`);
+ Deno.writeFileSync(fileUrl, data, { mode: 0o666 });
+
+ await Deno.chmod(fileUrl, 0o777);
+
+ const fileInfo = Deno.statSync(fileUrl);
+ assert(fileInfo.mode);
+ assertEquals(fileInfo.mode & 0o777, 0o777);
+
+ Deno.removeSync(tempDir, { recursive: true });
+ }
+);
+
// Check symlink when not on windows
unitTest(