summaryrefslogtreecommitdiff
path: root/cli/tests/unit/symlink_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/unit/symlink_test.ts')
-rw-r--r--cli/tests/unit/symlink_test.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/cli/tests/unit/symlink_test.ts b/cli/tests/unit/symlink_test.ts
index b5700b4f3..f0db2d615 100644
--- a/cli/tests/unit/symlink_test.ts
+++ b/cli/tests/unit/symlink_test.ts
@@ -1,6 +1,7 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
import {
assert,
+ assertRejects,
assertThrows,
pathToAbsoluteFileUrl,
unitTest,
@@ -47,6 +48,21 @@ unitTest(function symlinkSyncPerm() {
unitTest(
{ permissions: { read: true, write: true } },
+ function symlinkSyncAlreadyExist() {
+ const existingFile = Deno.makeTempFileSync();
+ const existingFile2 = Deno.makeTempFileSync();
+ assertThrows(
+ () => {
+ Deno.symlinkSync(existingFile, existingFile2);
+ },
+ Deno.errors.AlreadyExists,
+ `symlink '${existingFile}' -> '${existingFile2}'`,
+ );
+ },
+);
+
+unitTest(
+ { permissions: { read: true, write: true } },
async function symlinkSuccess() {
const testDir = Deno.makeTempDirSync();
const oldname = testDir + "/oldname";
@@ -77,3 +93,18 @@ unitTest(
assert(newNameInfoStat.isDirectory, "NOT DIRECTORY");
},
);
+
+unitTest(
+ { permissions: { read: true, write: true } },
+ async function symlinkAlreadyExist() {
+ const existingFile = Deno.makeTempFileSync();
+ const existingFile2 = Deno.makeTempFileSync();
+ await assertRejects(
+ async () => {
+ await Deno.symlink(existingFile, existingFile2);
+ },
+ Deno.errors.AlreadyExists,
+ `symlink '${existingFile}' -> '${existingFile2}'`,
+ );
+ },
+);