diff options
Diffstat (limited to 'cli/tests/unit/kv_test.ts')
-rw-r--r-- | cli/tests/unit/kv_test.ts | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/cli/tests/unit/kv_test.ts b/cli/tests/unit/kv_test.ts index 19081fd12..c98611e2d 100644 --- a/cli/tests/unit/kv_test.ts +++ b/cli/tests/unit/kv_test.ts @@ -702,6 +702,24 @@ dbTest("list prefix with start empty", async (db) => { assertEquals(entries.length, 0); }); +dbTest("list prefix with start equal to prefix", async (db) => { + await setupData(db); + await assertRejects( + async () => await collect(db.list({ prefix: ["a"], start: ["a"] })), + TypeError, + "start key is not in the keyspace defined by prefix", + ); +}); + +dbTest("list prefix with start out of bounds", async (db) => { + await setupData(db); + await assertRejects( + async () => await collect(db.list({ prefix: ["b"], start: ["a"] })), + TypeError, + "start key is not in the keyspace defined by prefix", + ); +}); + dbTest("list prefix with end", async (db) => { const versionstamp = await setupData(db); const entries = await collect(db.list({ prefix: ["a"], end: ["a", "c"] })); @@ -717,6 +735,24 @@ dbTest("list prefix with end empty", async (db) => { assertEquals(entries.length, 0); }); +dbTest("list prefix with end equal to prefix", async (db) => { + await setupData(db); + await assertRejects( + async () => await collect(db.list({ prefix: ["a"], end: ["a"] })), + TypeError, + "end key is not in the keyspace defined by prefix", + ); +}); + +dbTest("list prefix with end out of bounds", async (db) => { + await setupData(db); + await assertRejects( + async () => await collect(db.list({ prefix: ["a"], end: ["b"] })), + TypeError, + "end key is not in the keyspace defined by prefix", + ); +}); + dbTest("list prefix with empty prefix", async (db) => { const res = await db.set(["a"], 1); const entries = await collect(db.list({ prefix: [] })); @@ -1020,6 +1056,21 @@ dbTest("list range with manual cursor reverse", async (db) => { ]); }); +dbTest("list range with start greater than end", async (db) => { + await setupData(db); + await assertRejects( + async () => await collect(db.list({ start: ["b"], end: ["a"] })), + TypeError, + "start key is greater than end key", + ); +}); + +dbTest("list range with start equal to end", async (db) => { + await setupData(db); + const entries = await collect(db.list({ start: ["a"], end: ["a"] })); + assertEquals(entries.length, 0); +}); + dbTest("list invalid selector", async (db) => { await setupData(db); |