test(cli): align unit test permissions with runtime test permissions (#12189)

This commit is contained in:
Casper Beyer 2021-09-23 07:50:50 +08:00 committed by GitHub
parent 87e78802b0
commit 830586d242
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 664 additions and 574 deletions

View file

@ -7,7 +7,7 @@ import {
} from "./test_util.ts";
unitTest(
{ perms: { read: true, write: true } },
{ permissions: { read: true, write: true } },
function ftruncateSyncSuccess() {
const filename = Deno.makeTempDirSync() + "/test_ftruncateSync.txt";
const file = Deno.openSync(filename, {
@ -29,7 +29,7 @@ unitTest(
);
unitTest(
{ perms: { read: true, write: true } },
{ permissions: { read: true, write: true } },
async function ftruncateSuccess() {
const filename = Deno.makeTempDirSync() + "/test_ftruncate.txt";
const file = await Deno.open(filename, {
@ -51,7 +51,7 @@ unitTest(
);
unitTest(
{ perms: { read: true, write: true } },
{ permissions: { read: true, write: true } },
function truncateSyncSuccess() {
const filename = Deno.makeTempDirSync() + "/test_truncateSync.txt";
Deno.writeFileSync(filename, new Uint8Array(5));
@ -66,7 +66,7 @@ unitTest(
);
unitTest(
{ perms: { read: true, write: true } },
{ permissions: { read: true, write: true } },
async function truncateSuccess() {
const filename = Deno.makeTempDirSync() + "/test_truncate.txt";
await Deno.writeFile(filename, new Uint8Array(5));
@ -80,13 +80,13 @@ unitTest(
},
);
unitTest({ perms: { write: false } }, function truncateSyncPerm() {
unitTest({ permissions: { write: false } }, function truncateSyncPerm() {
assertThrows(() => {
Deno.truncateSync("/test_truncateSyncPermission.txt");
}, Deno.errors.PermissionDenied);
});
unitTest({ perms: { write: false } }, async function truncatePerm() {
unitTest({ permissions: { write: false } }, async function truncatePerm() {
await assertRejects(async () => {
await Deno.truncate("/test_truncatePermission.txt");
}, Deno.errors.PermissionDenied);