diff options
author | River <22485304+actual-size@users.noreply.github.com> | 2020-06-12 02:36:20 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-11 12:36:20 -0400 |
commit | 818a8010928cb8cef0b7043bd881c8cdce9b6efc (patch) | |
tree | 1502e74c9eb01901df8da118257d60d4f962b0e4 /cli/tests/unit/chown_test.ts | |
parent | 813210d4337bf6e174f1da1f1a6c6fb9b073afa2 (diff) |
feat: URL support in Deno filesystem methods (#5990)
Diffstat (limited to 'cli/tests/unit/chown_test.ts')
-rw-r--r-- | cli/tests/unit/chown_test.ts | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/cli/tests/unit/chown_test.ts b/cli/tests/unit/chown_test.ts index 724ea5a21..bcd5ab9fe 100644 --- a/cli/tests/unit/chown_test.ts +++ b/cli/tests/unit/chown_test.ts @@ -127,6 +127,26 @@ if (Deno.build.os !== "windows") { unitTest( { perms: { run: true, write: true } }, + async function chownSyncWithUrl(): Promise<void> { + // TODO: same as chownSyncSucceed + const { uid, gid } = await getUidAndGid(); + + const enc = new TextEncoder(); + const dirPath = Deno.makeTempDirSync(); + const fileUrl = new URL(`file://${dirPath}/chown_test_file.txt`); + const fileData = enc.encode("Hello"); + Deno.writeFileSync(fileUrl, fileData); + + // the test script creates this file with the same uid and gid, + // here chown is a noop so it succeeds under non-priviledged user + Deno.chownSync(fileUrl, uid, gid); + + Deno.removeSync(dirPath, { recursive: true }); + } + ); + + unitTest( + { perms: { run: true, write: true } }, async function chownSucceed(): Promise<void> { // TODO: same as chownSyncSucceed const { uid, gid } = await getUidAndGid(); @@ -144,4 +164,24 @@ if (Deno.build.os !== "windows") { Deno.removeSync(dirPath, { recursive: true }); } ); + + unitTest( + { perms: { run: true, write: true } }, + async function chownWithUrl(): Promise<void> { + // TODO: same as chownSyncSucceed + const { uid, gid } = await getUidAndGid(); + + const enc = new TextEncoder(); + const dirPath = await Deno.makeTempDir(); + const fileUrl = new URL(`file://${dirPath}/chown_test_file.txt`); + const fileData = enc.encode("Hello"); + await Deno.writeFile(fileUrl, fileData); + + // the test script creates this file with the same uid and gid, + // here chown is a noop so it succeeds under non-priviledged user + await Deno.chown(fileUrl, uid, gid); + + Deno.removeSync(dirPath, { recursive: true }); + } + ); } |