summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/unit/read_link_test.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/cli/tests/unit/read_link_test.ts b/cli/tests/unit/read_link_test.ts
index 0e8390f6a..5be070ac5 100644
--- a/cli/tests/unit/read_link_test.ts
+++ b/cli/tests/unit/read_link_test.ts
@@ -3,6 +3,7 @@ import {
assertEquals,
assertThrows,
assertThrowsAsync,
+ pathToAbsoluteFileUrl,
unitTest,
} from "./test_util.ts";
@@ -21,6 +22,21 @@ unitTest(
},
);
+unitTest(
+ { perms: { write: true, read: true } },
+ function readLinkSyncUrlSuccess(): void {
+ const testDir = Deno.makeTempDirSync();
+ const target = testDir +
+ (Deno.build.os == "windows" ? "\\target" : "/target");
+ const symlink = testDir +
+ (Deno.build.os == "windows" ? "\\symlink" : "/symlink");
+ Deno.mkdirSync(target);
+ Deno.symlinkSync(target, symlink);
+ const targetPath = Deno.readLinkSync(pathToAbsoluteFileUrl(symlink));
+ assertEquals(targetPath, target);
+ },
+);
+
unitTest({ perms: { read: false } }, function readLinkSyncPerm(): void {
assertThrows(() => {
Deno.readLinkSync("/symlink");
@@ -48,6 +64,21 @@ unitTest(
},
);
+unitTest(
+ { perms: { write: true, read: true } },
+ async function readLinkUrlSuccess(): Promise<void> {
+ const testDir = Deno.makeTempDirSync();
+ const target = testDir +
+ (Deno.build.os == "windows" ? "\\target" : "/target");
+ const symlink = testDir +
+ (Deno.build.os == "windows" ? "\\symlink" : "/symlink");
+ Deno.mkdirSync(target);
+ Deno.symlinkSync(target, symlink);
+ const targetPath = await Deno.readLink(pathToAbsoluteFileUrl(symlink));
+ assertEquals(targetPath, target);
+ },
+);
+
unitTest({ perms: { read: false } }, async function readLinkPerm(): Promise<
void
> {