summaryrefslogtreecommitdiff
path: root/std/fs/copy_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'std/fs/copy_test.ts')
-rw-r--r--std/fs/copy_test.ts96
1 files changed, 48 insertions, 48 deletions
diff --git a/std/fs/copy_test.ts b/std/fs/copy_test.ts
index dd9b90ff6..75efd7cc0 100644
--- a/std/fs/copy_test.ts
+++ b/std/fs/copy_test.ts
@@ -17,7 +17,7 @@ const testdataDir = path.resolve("fs", "testdata");
function testCopy(
name: string,
cb: (tempDir: string) => Promise<void>,
- ignore = false
+ ignore = false,
): void {
Deno.test({
name,
@@ -34,7 +34,7 @@ function testCopy(
function testCopyIgnore(
name: string,
- cb: (tempDir: string) => Promise<void>
+ cb: (tempDir: string) => Promise<void>,
): void {
testCopy(name, cb, true);
}
@@ -60,9 +60,9 @@ testCopy(
await assertThrowsAsync(
async (): Promise<void> => {
await copy(srcFile, destFile);
- }
+ },
);
- }
+ },
);
testCopy(
@@ -75,9 +75,9 @@ testCopy(
await copy(srcFile, destFile);
},
Error,
- "Source and destination cannot be the same."
+ "Source and destination cannot be the same.",
);
- }
+ },
);
testCopy(
@@ -91,12 +91,12 @@ testCopy(
assertEquals(
await exists(srcFile),
true,
- `source should exist before copy`
+ `source should exist before copy`,
);
assertEquals(
await exists(destFile),
false,
- "destination should not exist before copy"
+ "destination should not exist before copy",
);
await copy(srcFile, destFile);
@@ -105,7 +105,7 @@ testCopy(
assertEquals(
await exists(destFile),
true,
- "destination should exist before copy"
+ "destination should exist before copy",
);
const destContent = new TextDecoder().decode(await Deno.readFile(destFile));
@@ -113,7 +113,7 @@ testCopy(
assertEquals(
srcContent,
destContent,
- "source and destination should have the same content"
+ "source and destination should have the same content",
);
// Copy again and it should throw an error.
@@ -122,7 +122,7 @@ testCopy(
await copy(srcFile, destFile);
},
Error,
- `'${destFile}' already exists.`
+ `'${destFile}' already exists.`,
);
// Modify destination file.
@@ -130,7 +130,7 @@ testCopy(
assertEquals(
new TextDecoder().decode(await Deno.readFile(destFile)),
- "txt copy"
+ "txt copy",
);
// Copy again with overwrite option.
@@ -139,9 +139,9 @@ testCopy(
// Make sure the file has been overwritten.
assertEquals(
new TextDecoder().decode(await Deno.readFile(destFile)),
- "txt"
+ "txt",
);
- }
+ },
);
// TODO(#6644) This case is ignored because of the issue #5065.
@@ -168,7 +168,7 @@ testCopyIgnore(
assert(destStatInfo.mtime instanceof Date);
assertEquals(destStatInfo.atime, srcStatInfo.atime);
assertEquals(destStatInfo.mtime, srcStatInfo.mtime);
- }
+ },
);
testCopy(
@@ -184,9 +184,9 @@ testCopy(
await copy(srcDir, destDir);
},
Error,
- `Cannot copy '${srcDir}' to a subdirectory of itself, '${destDir}'.`
+ `Cannot copy '${srcDir}' to a subdirectory of itself, '${destDir}'.`,
);
- }
+ },
);
testCopy(
@@ -203,9 +203,9 @@ testCopy(
await copy(srcDir, destDir);
},
Error,
- `Cannot overwrite non-directory '${destDir}' with directory '${srcDir}'.`
+ `Cannot overwrite non-directory '${destDir}' with directory '${srcDir}'.`,
);
- }
+ },
);
testCopy(
@@ -226,11 +226,11 @@ testCopy(
// After copy. The source and destination should have the same content.
assertEquals(
new TextDecoder().decode(await Deno.readFile(srcFile)),
- new TextDecoder().decode(await Deno.readFile(destFile))
+ new TextDecoder().decode(await Deno.readFile(destFile)),
);
assertEquals(
new TextDecoder().decode(await Deno.readFile(srcNestFile)),
- new TextDecoder().decode(await Deno.readFile(destNestFile))
+ new TextDecoder().decode(await Deno.readFile(destNestFile)),
);
// Copy again without overwrite option and it should throw an error.
@@ -239,14 +239,14 @@ testCopy(
await copy(srcDir, destDir);
},
Error,
- `'${destDir}' already exists.`
+ `'${destDir}' already exists.`,
);
// Modify the file in the destination directory.
await Deno.writeFile(destNestFile, new TextEncoder().encode("nest copy"));
assertEquals(
new TextDecoder().decode(await Deno.readFile(destNestFile)),
- "nest copy"
+ "nest copy",
);
// Copy again with overwrite option.
@@ -255,9 +255,9 @@ testCopy(
// Make sure the file has been overwritten.
assertEquals(
new TextDecoder().decode(await Deno.readFile(destNestFile)),
- "nest"
+ "nest",
);
- }
+ },
);
testCopy(
@@ -269,7 +269,7 @@ testCopy(
assert(
(await Deno.lstat(srcLink)).isSymlink,
- `'${srcLink}' should be symlink type`
+ `'${srcLink}' should be symlink type`,
);
await copy(srcLink, destLink);
@@ -277,7 +277,7 @@ testCopy(
const statInfo = await Deno.lstat(destLink);
assert(statInfo.isSymlink, `'${destLink}' should be symlink type`);
- }
+ },
);
testCopy(
@@ -291,7 +291,7 @@ testCopy(
assert(
(await Deno.lstat(srcLink)).isSymlink,
- `'${srcLink}' should be symlink type`
+ `'${srcLink}' should be symlink type`,
);
await copy(srcLink, destLink);
@@ -299,7 +299,7 @@ testCopy(
const statInfo = await Deno.lstat(destLink);
assert(statInfo.isSymlink);
- }
+ },
);
testCopySync(
@@ -310,7 +310,7 @@ testCopySync(
assertThrows((): void => {
copySync(srcFile, destFile);
});
- }
+ },
);
testCopySync(
@@ -338,7 +338,7 @@ testCopySync(
// is fixed
// assertEquals(destStatInfo.atime, srcStatInfo.atime);
// assertEquals(destStatInfo.mtime, srcStatInfo.mtime);
- }
+ },
);
testCopySync(
@@ -350,9 +350,9 @@ testCopySync(
copySync(srcFile, srcFile);
},
Error,
- "Source and destination cannot be the same."
+ "Source and destination cannot be the same.",
);
- }
+ },
);
testCopySync("[fs] copy file synchronously", (tempDir: string): void => {
@@ -379,7 +379,7 @@ testCopySync("[fs] copy file synchronously", (tempDir: string): void => {
copySync(srcFile, destFile);
},
Error,
- `'${destFile}' already exists.`
+ `'${destFile}' already exists.`,
);
// Modify destination file.
@@ -387,7 +387,7 @@ testCopySync("[fs] copy file synchronously", (tempDir: string): void => {
assertEquals(
new TextDecoder().decode(Deno.readFileSync(destFile)),
- "txt copy"
+ "txt copy",
);
// Copy again with overwrite option.
@@ -410,9 +410,9 @@ testCopySync(
copySync(srcDir, destDir);
},
Error,
- `Cannot copy '${srcDir}' to a subdirectory of itself, '${destDir}'.`
+ `Cannot copy '${srcDir}' to a subdirectory of itself, '${destDir}'.`,
);
- }
+ },
);
testCopySync(
@@ -430,9 +430,9 @@ testCopySync(
copySync(srcDir, destDir);
},
Error,
- `Cannot overwrite non-directory '${destDir}' with directory '${srcDir}'.`
+ `Cannot overwrite non-directory '${destDir}' with directory '${srcDir}'.`,
);
- }
+ },
);
testCopySync("[fs] copy directory synchronously", (tempDir: string): void => {
@@ -451,11 +451,11 @@ testCopySync("[fs] copy directory synchronously", (tempDir: string): void => {
// After copy. The source and destination should have the same content.
assertEquals(
new TextDecoder().decode(Deno.readFileSync(srcFile)),
- new TextDecoder().decode(Deno.readFileSync(destFile))
+ new TextDecoder().decode(Deno.readFileSync(destFile)),
);
assertEquals(
new TextDecoder().decode(Deno.readFileSync(srcNestFile)),
- new TextDecoder().decode(Deno.readFileSync(destNestFile))
+ new TextDecoder().decode(Deno.readFileSync(destNestFile)),
);
// Copy again without overwrite option and it should throw an error.
@@ -464,14 +464,14 @@ testCopySync("[fs] copy directory synchronously", (tempDir: string): void => {
copySync(srcDir, destDir);
},
Error,
- `'${destDir}' already exists.`
+ `'${destDir}' already exists.`,
);
// Modify the file in the destination directory.
Deno.writeFileSync(destNestFile, new TextEncoder().encode("nest copy"));
assertEquals(
new TextDecoder().decode(Deno.readFileSync(destNestFile)),
- "nest copy"
+ "nest copy",
);
// Copy again with overwrite option.
@@ -480,7 +480,7 @@ testCopySync("[fs] copy directory synchronously", (tempDir: string): void => {
// Make sure the file has been overwritten.
assertEquals(
new TextDecoder().decode(Deno.readFileSync(destNestFile)),
- "nest"
+ "nest",
);
});
@@ -493,7 +493,7 @@ testCopySync(
assert(
Deno.lstatSync(srcLink).isSymlink,
- `'${srcLink}' should be symlink type`
+ `'${srcLink}' should be symlink type`,
);
copySync(srcLink, destLink);
@@ -501,7 +501,7 @@ testCopySync(
const statInfo = Deno.lstatSync(destLink);
assert(statInfo.isSymlink, `'${destLink}' should be symlink type`);
- }
+ },
);
testCopySync(
@@ -515,7 +515,7 @@ testCopySync(
assert(
Deno.lstatSync(srcLink).isSymlink,
- `'${srcLink}' should be symlink type`
+ `'${srcLink}' should be symlink type`,
);
copySync(srcLink, destLink);
@@ -523,5 +523,5 @@ testCopySync(
const statInfo = Deno.lstatSync(destLink);
assert(statInfo.isSymlink);
- }
+ },
);