cultcache-ts: test that an envelope without a catalog entry replaces and deletes
StrykerJS on 142a2e13 left two OptionalChaining survivors in isSameRecord:
nothing wrote through the store with an envelope that has no catalog entry,
which is what an external CacheBackingStore caller sends. This test pushes,
rewrites and deletes such an envelope.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
142a2e1385
commit
e8b3e4ca79
1 changed files with 11 additions and 0 deletions
|
|
@ -1754,3 +1754,14 @@ test("a store keeps a record of another schema at the same key, and the same sch
|
|||
await store.delete(identityEnvelope("j", "label-c", "id-c", "name-c"));
|
||||
assert.deepEqual(await recordsOnDisk(file), [["j", "id-a"], ["k", "id-b"], ["k", "id-a"]]);
|
||||
});
|
||||
|
||||
test("a store replaces and deletes a record written by an envelope that carries no catalog entry", async () => {
|
||||
const file = join(await mkdtemp(join(tmpdir(), "cultcache-identity-")), "store.cc");
|
||||
const store = new SingleFileMessagePackBackingStore(file);
|
||||
const raw = (payload: number): CultCacheEnvelope => ({ key: "k", type: "t", payload: Uint8Array.of(payload), storedAt: "2026-09-30T00:00:00Z" });
|
||||
await store.push(raw(0x01));
|
||||
await store.push(raw(0x02));
|
||||
assert.deepEqual((await store.pullAll()).map((record) => [record.key, [...record.payload]]), [["k", [0x02]]]);
|
||||
await store.delete(raw(0x02));
|
||||
assert.deepEqual(await recordsOnDisk(file), []);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue