From a455a0babf4930a2476a70144923828073c19e68 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Thu, 25 Jun 2020 19:27:23 +0800 Subject: [PATCH] Fix readLinkSync and readLink tests on Windows (#6463) --- cli/tests/unit/read_link_test.ts | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/cli/tests/unit/read_link_test.ts b/cli/tests/unit/read_link_test.ts index 524b67923f..597541914b 100644 --- a/cli/tests/unit/read_link_test.ts +++ b/cli/tests/unit/read_link_test.ts @@ -10,16 +10,14 @@ unitTest( { perms: { write: true, read: true } }, function readLinkSyncSuccess(): void { const testDir = Deno.makeTempDirSync(); - const target = testDir + "/target"; - const symlink = testDir + "/symln"; + const target = + testDir + (Deno.build.os == "windows" ? "\\target" : "/target"); + const symlink = + testDir + (Deno.build.os == "windows" ? "\\symlink" : "/symlink"); Deno.mkdirSync(target); - // TODO Add test for Windows once symlink is implemented for Windows. - // See https://github.com/denoland/deno/issues/815. - if (Deno.build.os !== "windows") { - Deno.symlinkSync(target, symlink); - const targetPath = Deno.readLinkSync(symlink); - assertEquals(targetPath, target); - } + Deno.symlinkSync(target, symlink); + const targetPath = Deno.readLinkSync(symlink); + assertEquals(targetPath, target); } ); @@ -39,16 +37,14 @@ unitTest( { perms: { write: true, read: true } }, async function readLinkSuccess(): Promise { const testDir = Deno.makeTempDirSync(); - const target = testDir + "/target"; - const symlink = testDir + "/symln"; + const target = + testDir + (Deno.build.os == "windows" ? "\\target" : "/target"); + const symlink = + testDir + (Deno.build.os == "windows" ? "\\symlink" : "/symlink"); Deno.mkdirSync(target); - // TODO Add test for Windows once symlink is implemented for Windows. - // See https://github.com/denoland/deno/issues/815. - if (Deno.build.os !== "windows") { - Deno.symlinkSync(target, symlink); - const targetPath = await Deno.readLink(symlink); - assertEquals(targetPath, target); - } + Deno.symlinkSync(target, symlink); + const targetPath = await Deno.readLink(symlink); + assertEquals(targetPath, target); } );