Skip to content

Commit 560ce74

Browse files
authored
update permissions samples on testing.md (#1664)
1 parent 065eae9 commit 560ce74

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

runtime/fundamentals/testing.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ Deno.test("async test", async () => {
4848

4949
Deno.test({
5050
name: "read file test",
51-
permissions: { read: true },
5251
fn: () => {
5352
const data = Deno.readTextFileSync("./somefile.txt");
5453
assertEquals(data, "expected content");
@@ -97,7 +96,7 @@ deno test my_test.ts -- -e --foo --bar
9796

9897
# Provide permission for deno to read from the filesystem, which is necessary
9998
# for the final test above to pass
100-
deno test --allow-read my_test.ts
99+
deno test --allow-read=. my_test.ts
101100
```
102101

103102
## Test Steps
@@ -611,7 +610,7 @@ import getFileText from "./main.ts";
611610

612611
Deno.test({
613612
name: "File reader gets text with permission",
614-
permissions: { read: true },
613+
// no `permissions` means "inherit"
615614
fn: async () => {
616615
const result = await getFileText();
617616
console.log(result);
@@ -640,11 +639,10 @@ The permissions object supports detailed configuration:
640639
```ts
641640
Deno.test({
642641
name: "permission configuration example",
642+
// permissions: { read: true } // Grant all read permissions and deny all others
643+
// OR
643644
permissions: {
644-
read: true, // Grant all read permissions
645-
// OR
646645
read: ["./data", "./config"], // Grant read to specific paths only
647-
648646
write: false, // Explicitly deny write permissions
649647
net: ["example.com:443"], // Allow specific host:port combinations
650648
env: ["API_KEY"], // Allow access to specific env variables

0 commit comments

Comments
 (0)