gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: idb-bridge: add test for upda


From: gnunet
Subject: [taler-wallet-core] branch master updated: idb-bridge: add test for updating the same record with/without index key
Date: Wed, 12 Jan 2022 16:04:22 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new dd66e43b idb-bridge: add test for updating the same record 
with/without index key
dd66e43b is described below

commit dd66e43b3ceb3e393f399ac5544941de8912c59d
Author: Florian Dold <florian@dold.me>
AuthorDate: Wed Jan 12 16:04:19 2022 +0100

    idb-bridge: add test for updating the same record with/without index key
---
 packages/idb-bridge/src/MemoryBackend.test.ts | 53 +++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/packages/idb-bridge/src/MemoryBackend.test.ts 
b/packages/idb-bridge/src/MemoryBackend.test.ts
index ac1a9d90..3c5e13df 100644
--- a/packages/idb-bridge/src/MemoryBackend.test.ts
+++ b/packages/idb-bridge/src/MemoryBackend.test.ts
@@ -356,6 +356,59 @@ test("export", async (t) => {
   t.pass();
 });
 
+test("update with non-existent index values", async (t) => {
+  const backend = new MemoryBackend();
+  backend.enableTracing = true;
+  const idb = new BridgeIDBFactory(backend);
+  const request = idb.open("mydb");
+  request.onupgradeneeded = () => {
+    const db = request.result;
+    const store = db.createObjectStore("bla", { keyPath: "x" });
+    store.createIndex("by_y", "y");
+    store.createIndex("by_z", "z");
+  };
+
+  const db: BridgeIDBDatabase = await promiseFromRequest(request);
+
+  t.is(db.name, "mydb");
+
+  {
+    const tx = db.transaction("bla", "readwrite");
+    const store = tx.objectStore("bla");
+    store.put({ x: 0, y: "a", z: 42 });
+    const index = store.index("by_z");
+    const indRes = await promiseFromRequest(index.get(42));
+    t.is(indRes.x, 0);
+    const res = await promiseFromRequest(store.get(0));
+    t.is(res.z, 42);
+    await promiseFromTransaction(tx);
+  }
+
+  {
+    const tx = db.transaction("bla", "readwrite");
+    const store = tx.objectStore("bla");
+    store.put({ x: 0, y: "a" });
+    const res = await promiseFromRequest(store.get(0));
+    t.is(res.z, undefined);
+    await promiseFromTransaction(tx);
+  }
+
+  {
+    const tx = db.transaction("bla", "readwrite");
+    const store = tx.objectStore("bla");
+    const index = store.index("by_z");
+    {
+      const indRes = await promiseFromRequest(index.get(42));
+      t.is(indRes, undefined);
+    }
+    const res = await promiseFromRequest(store.get(0));
+    t.is(res.z, undefined);
+    await promiseFromTransaction(tx);
+  }
+
+  t.pass();
+});
+
 test("range queries", async (t) => {
   const backend = new MemoryBackend();
   backend.enableTracing = true;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]