diff options
Diffstat (limited to 'cli/js/tests')
-rw-r--r-- | cli/js/tests/remove_test.ts | 128 | ||||
-rw-r--r-- | cli/js/tests/symlink_test.ts | 62 |
2 files changed, 64 insertions, 126 deletions
diff --git a/cli/js/tests/remove_test.ts b/cli/js/tests/remove_test.ts index 8de577838..35e5c821e 100644 --- a/cli/js/tests/remove_test.ts +++ b/cli/js/tests/remove_test.ts @@ -83,27 +83,23 @@ unitTest( { perms: { write: true, read: true } }, function removeSyncDanglingSymlinkSuccess(): void { const danglingSymlinkPath = Deno.makeTempDirSync() + "/dangling_symlink"; - // TODO(#3832): Remove "not Implemented" error checking when symlink creation is implemented for Windows - let errOnWindows; - try { - Deno.symlinkSync("unexistent_file", danglingSymlinkPath); - } catch (err) { - errOnWindows = err; - } if (Deno.build.os === "windows") { - assertEquals(errOnWindows.message, "not implemented"); + Deno.symlinkSync("unexistent_file", danglingSymlinkPath, { + type: "file", + }); } else { - const pathInfo = Deno.lstatSync(danglingSymlinkPath); - assert(pathInfo.isSymlink); - Deno.removeSync(danglingSymlinkPath); - let err; - try { - Deno.lstatSync(danglingSymlinkPath); - } catch (e) { - err = e; - } - assert(err instanceof Deno.errors.NotFound); + Deno.symlinkSync("unexistent_file", danglingSymlinkPath); + } + const pathInfo = Deno.lstatSync(danglingSymlinkPath); + assert(pathInfo.isSymlink); + Deno.removeSync(danglingSymlinkPath); + let err; + try { + Deno.lstatSync(danglingSymlinkPath); + } catch (e) { + err = e; } + assert(err instanceof Deno.errors.NotFound); } ); @@ -116,28 +112,22 @@ unitTest( const filePath = tempDir + "/test.txt"; const validSymlinkPath = tempDir + "/valid_symlink"; Deno.writeFileSync(filePath, data, { mode: 0o666 }); - // TODO(#3832): Remove "not Implemented" error checking when symlink creation is implemented for Windows - let errOnWindows; - try { - Deno.symlinkSync(filePath, validSymlinkPath); - } catch (err) { - errOnWindows = err; - } if (Deno.build.os === "windows") { - assertEquals(errOnWindows.message, "not implemented"); + Deno.symlinkSync(filePath, validSymlinkPath, { type: "file" }); } else { - const symlinkPathInfo = Deno.statSync(validSymlinkPath); - assert(symlinkPathInfo.isFile); - Deno.removeSync(validSymlinkPath); - let err; - try { - Deno.statSync(validSymlinkPath); - } catch (e) { - err = e; - } - Deno.removeSync(filePath); - assert(err instanceof Deno.errors.NotFound); + Deno.symlinkSync(filePath, validSymlinkPath); + } + const symlinkPathInfo = Deno.statSync(validSymlinkPath); + assert(symlinkPathInfo.isFile); + Deno.removeSync(validSymlinkPath); + let err; + try { + Deno.statSync(validSymlinkPath); + } catch (e) { + err = e; } + Deno.removeSync(filePath); + assert(err instanceof Deno.errors.NotFound); } ); @@ -319,27 +309,23 @@ unitTest( { perms: { write: true, read: true } }, async function removeDanglingSymlinkSuccess(): Promise<void> { const danglingSymlinkPath = Deno.makeTempDirSync() + "/dangling_symlink"; - // TODO(#3832): Remove "not Implemented" error checking when symlink creation is implemented for Windows - let errOnWindows; - try { - Deno.symlinkSync("unexistent_file", danglingSymlinkPath); - } catch (e) { - errOnWindows = e; - } if (Deno.build.os === "windows") { - assertEquals(errOnWindows.message, "not implemented"); + Deno.symlinkSync("unexistent_file", danglingSymlinkPath, { + type: "file", + }); } else { - const pathInfo = Deno.lstatSync(danglingSymlinkPath); - assert(pathInfo.isSymlink); - await Deno.remove(danglingSymlinkPath); - let err; - try { - Deno.lstatSync(danglingSymlinkPath); - } catch (e) { - err = e; - } - assert(err instanceof Deno.errors.NotFound); + Deno.symlinkSync("unexistent_file", danglingSymlinkPath); + } + const pathInfo = Deno.lstatSync(danglingSymlinkPath); + assert(pathInfo.isSymlink); + await Deno.remove(danglingSymlinkPath); + let err; + try { + Deno.lstatSync(danglingSymlinkPath); + } catch (e) { + err = e; } + assert(err instanceof Deno.errors.NotFound); } ); @@ -352,28 +338,22 @@ unitTest( const filePath = tempDir + "/test.txt"; const validSymlinkPath = tempDir + "/valid_symlink"; Deno.writeFileSync(filePath, data, { mode: 0o666 }); - // TODO(#3832): Remove "not Implemented" error checking when symlink creation is implemented for Windows - let errOnWindows; - try { - Deno.symlinkSync(filePath, validSymlinkPath); - } catch (e) { - errOnWindows = e; - } if (Deno.build.os === "windows") { - assertEquals(errOnWindows.message, "not implemented"); + Deno.symlinkSync(filePath, validSymlinkPath, { type: "file" }); } else { - const symlinkPathInfo = Deno.statSync(validSymlinkPath); - assert(symlinkPathInfo.isFile); - await Deno.remove(validSymlinkPath); - let err; - try { - Deno.statSync(validSymlinkPath); - } catch (e) { - err = e; - } - Deno.removeSync(filePath); - assert(err instanceof Deno.errors.NotFound); + Deno.symlinkSync(filePath, validSymlinkPath); + } + const symlinkPathInfo = Deno.statSync(validSymlinkPath); + assert(symlinkPathInfo.isFile); + await Deno.remove(validSymlinkPath); + let err; + try { + Deno.statSync(validSymlinkPath); + } catch (e) { + err = e; } + Deno.removeSync(filePath); + assert(err instanceof Deno.errors.NotFound); } ); diff --git a/cli/js/tests/symlink_test.ts b/cli/js/tests/symlink_test.ts index 681ace1db..505a49bab 100644 --- a/cli/js/tests/symlink_test.ts +++ b/cli/js/tests/symlink_test.ts @@ -8,22 +8,12 @@ unitTest( const oldname = testDir + "/oldname"; const newname = testDir + "/newname"; Deno.mkdirSync(oldname); - let errOnWindows; // Just for now, until we implement symlink for Windows. - try { - Deno.symlinkSync(oldname, newname); - } catch (e) { - errOnWindows = e; - } - if (errOnWindows) { - assertEquals(Deno.build.os, "windows"); - assertEquals(errOnWindows.message, "not implemented"); - } else { - const newNameInfoLStat = Deno.lstatSync(newname); - const newNameInfoStat = Deno.statSync(newname); - assert(newNameInfoLStat.isSymlink); - assert(newNameInfoStat.isDirectory); - } + Deno.symlinkSync(oldname, newname); + const newNameInfoLStat = Deno.lstatSync(newname); + const newNameInfoStat = Deno.statSync(newname); + assert(newNameInfoLStat.isSymlink); + assert(newNameInfoStat.isDirectory); } ); @@ -38,28 +28,6 @@ unitTest(function symlinkSyncPerm(): void { assertEquals(err.name, "PermissionDenied"); }); -// Just for now, until we implement symlink for Windows. -// Symlink with type should succeed on other platforms with type ignored -unitTest( - { perms: { write: true } }, - function symlinkSyncNotImplemented(): void { - const testDir = Deno.makeTempDirSync(); - const oldname = testDir + "/oldname"; - const newname = testDir + "/newname"; - let err; - try { - Deno.symlinkSync(oldname, newname, "dir"); - } catch (e) { - err = e; - } - if (err) { - assertEquals(Deno.build.os, "windows"); - // from cli/js/util.ts:notImplemented - assertEquals(err.message, "not implemented"); - } - } -); - unitTest( { perms: { read: true, write: true } }, async function symlinkSuccess(): Promise<void> { @@ -67,20 +35,10 @@ unitTest( const oldname = testDir + "/oldname"; const newname = testDir + "/newname"; Deno.mkdirSync(oldname); - let errOnWindows; - // Just for now, until we implement symlink for Windows. - try { - await Deno.symlink(oldname, newname); - } catch (e) { - errOnWindows = e; - } - if (errOnWindows) { - assertEquals(errOnWindows.message, "not implemented"); - } else { - const newNameInfoLStat = Deno.lstatSync(newname); - const newNameInfoStat = Deno.statSync(newname); - assert(newNameInfoLStat.isSymlink); - assert(newNameInfoStat.isDirectory); - } + await Deno.symlink(oldname, newname); + const newNameInfoLStat = Deno.lstatSync(newname); + const newNameInfoStat = Deno.statSync(newname); + assert(newNameInfoLStat.isSymlink, "NOT SYMLINK"); + assert(newNameInfoStat.isDirectory, "NOT DIRECTORY"); } ); |