diff options
author | William Perron <hey@wperron.io> | 2020-11-23 16:11:56 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-23 22:11:56 +0100 |
commit | 266925d772527c9ba5fbc094e67cade31fc35a47 (patch) | |
tree | 06187faa63b4ebceddc47daab129b5f9fc5f2024 /cli/tests | |
parent | 46850918e7e6215cc56e163ae4a42c49cd05b446 (diff) |
fix(cli): add file URL support for Deno.readLink (#8423)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit/read_link_test.ts | 31 |
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 > { |