summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2023-03-22 10:49:29 +0000
committerGitHub <noreply@github.com>2023-03-22 06:49:29 -0400
commit5804d7434e4f60e98c94a6862ec4c1d068ec0650 (patch)
treefb2ca69bbf802089ba3081660af34bf397aeca22 /cli
parent92ebf4afe5d55135b3ba39616bcb77106c07c597 (diff)
fix(ext/kv): don't request permissions for ":memory:" (#18346)
Currently `Deno.openKv(":memory:")` requests read+write permissions for `./:memory:` even though no file is read or written. Also added some guards for special sqlite paths that were unintentionally opted into.
Diffstat (limited to 'cli')
-rw-r--r--cli/tests/unit/kv_test.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/cli/tests/unit/kv_test.ts b/cli/tests/unit/kv_test.ts
index 7bb4656c1..c50e52c52 100644
--- a/cli/tests/unit/kv_test.ts
+++ b/cli/tests/unit/kv_test.ts
@@ -7,6 +7,32 @@ import {
assertThrows,
} from "./test_util.ts";
+Deno.test({
+ name: "openKv :memory: no permissions",
+ permissions: {},
+ async fn() {
+ const db = await Deno.openKv(":memory:");
+ await db.close();
+ },
+});
+
+Deno.test({
+ name: "openKv invalid filenames",
+ permissions: {},
+ async fn() {
+ await assertRejects(
+ async () => await Deno.openKv(""),
+ TypeError,
+ "Filename cannot be empty",
+ );
+ await assertRejects(
+ async () => await Deno.openKv(":foo"),
+ TypeError,
+ "Filename cannot start with ':' unless prefixed with './'",
+ );
+ },
+});
+
function dbTest(name: string, fn: (db: Deno.Kv) => Promise<void>) {
Deno.test({
name,