diff options
author | Casper Beyer <caspervonb@pm.me> | 2021-06-03 22:14:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-03 16:14:37 +0200 |
commit | dc69b03339cc75af1daa70700d1283fa33c22c3b (patch) | |
tree | f7df713b978809938bdf9dd42d90805a89bea380 /cli/tests | |
parent | 844a1317ec63e5ed5019e36a52dc3e7d3abfab8b (diff) |
feat(runtime): support URL overloads for Deno.rename/Deno.renameSync (#10512)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit/rename_test.ts | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/cli/tests/unit/rename_test.ts b/cli/tests/unit/rename_test.ts index 09633aed7..711b63aa7 100644 --- a/cli/tests/unit/rename_test.ts +++ b/cli/tests/unit/rename_test.ts @@ -1,5 +1,11 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -import { assert, assertEquals, assertThrows, unitTest } from "./test_util.ts"; +import { + assert, + assertEquals, + assertThrows, + pathToAbsoluteFileUrl, + unitTest, +} from "./test_util.ts"; function assertMissing(path: string): void { let caughtErr = false; @@ -41,6 +47,22 @@ unitTest( ); unitTest( + { perms: { read: true, write: true } }, + function renameSyncWithURL(): void { + const testDir = Deno.makeTempDirSync(); + const oldpath = testDir + "/oldpath"; + const newpath = testDir + "/newpath"; + Deno.mkdirSync(oldpath); + Deno.renameSync( + pathToAbsoluteFileUrl(oldpath), + pathToAbsoluteFileUrl(newpath), + ); + assertDirectory(newpath); + assertMissing(oldpath); + }, +); + +unitTest( { perms: { read: false, write: true } }, function renameSyncReadPerm(): void { assertThrows(() => { @@ -75,6 +97,22 @@ unitTest( }, ); +unitTest( + { perms: { read: true, write: true } }, + async function renameWithURL(): Promise<void> { + const testDir = Deno.makeTempDirSync(); + const oldpath = testDir + "/oldpath"; + const newpath = testDir + "/newpath"; + Deno.mkdirSync(oldpath); + await Deno.rename( + pathToAbsoluteFileUrl(oldpath), + pathToAbsoluteFileUrl(newpath), + ); + assertDirectory(newpath); + assertMissing(oldpath); + }, +); + function readFileString(filename: string): string { const dataRead = Deno.readFileSync(filename); const dec = new TextDecoder("utf-8"); |