summaryrefslogtreecommitdiff
path: root/cli/tests/unit
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2023-04-11 16:36:01 +0200
committerGitHub <noreply@github.com>2023-04-11 14:36:01 +0000
commite0bf8e6faf58c8120738215a1aa05adbd79289c3 (patch)
treee26d0dd8767c21cbda83f96ed8e8183bc3e6f6f4 /cli/tests/unit
parent015eb4ef9c99526486e372489dcc50feb7b39ea6 (diff)
fix(ext/kv): keys must be arrays (#18655)
There was some leftover code from previous iterations, where keys could be single parts instead of arrays also. This didn't match the types.
Diffstat (limited to 'cli/tests/unit')
-rw-r--r--cli/tests/unit/kv_test.ts45
1 files changed, 45 insertions, 0 deletions
diff --git a/cli/tests/unit/kv_test.ts b/cli/tests/unit/kv_test.ts
index 69eb8bed9..60cf11b8e 100644
--- a/cli/tests/unit/kv_test.ts
+++ b/cli/tests/unit/kv_test.ts
@@ -1138,6 +1138,51 @@ dbTest("operation size limit", async (db) => {
);
});
+dbTest("keys must be arrays", async (db) => {
+ await assertRejects(
+ // @ts-expect-error invalid type
+ async () => await db.get("a"),
+ TypeError,
+ );
+
+ await assertRejects(
+ // @ts-expect-error invalid type
+ async () => await db.getMany(["a"]),
+ TypeError,
+ );
+
+ await assertRejects(
+ // @ts-expect-error invalid type
+ async () => await db.set("a", 1),
+ TypeError,
+ );
+
+ await assertRejects(
+ // @ts-expect-error invalid type
+ async () => await db.delete("a"),
+ TypeError,
+ );
+
+ await assertRejects(
+ async () =>
+ await db.atomic()
+ // @ts-expect-error invalid type
+ .mutate({ key: "a", type: "set", value: 1 } satisfies Deno.KvMutation)
+ .commit(),
+ TypeError,
+ );
+
+ await assertRejects(
+ async () =>
+ await db.atomic()
+ // @ts-expect-error invalid type
+ .check({ key: "a", versionstamp: null })
+ .set(["a"], 1)
+ .commit(),
+ TypeError,
+ );
+});
+
// This function is never called, it is just used to check that all the types
// are behaving as expected.
async function _typeCheckingTests() {