Skip to content

Commit 9622520

Browse files
authored
test(kv): update TTL test behavior to align with markerTTL and delay logic changes (#306)
Adjusted values for `markerTTL` and entry TTL during test execution. Added assertions to verify the correct operation type and timings for `DEL`, `PURGE`, and null entry states. Improved delay handling and simplified duration checks for test reliability. Signed-off-by: Alberto Ricart <[email protected]>
1 parent bb93b71 commit 9622520

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

kv/tests/kv_test.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,22 +2222,26 @@ Deno.test("kv - entries ttl markerTTL", async () => {
22222222
await cleanup(ns, nc);
22232223
});
22242224

2225-
Deno.test("kv - get entry ttl markerTTL", async () => {
2225+
Deno.test("kv - get entry ttl markerTTL from bucket", async () => {
22262226
const { ns, nc } = await setup(
22272227
jetstreamServerConf({}),
22282228
);
22292229
if (await notCompatible(ns, nc, "2.11.0")) {
22302230
return;
22312231
}
22322232
const kvm = await new Kvm(nc);
2233-
const kv = await kvm.create("A", { markerTTL: 2000 });
2234-
await kv.create("a", Empty, "1s");
2233+
const kv = await kvm.create("A", { markerTTL: 1000 });
2234+
await kv.create("a", Empty, "2s");
22352235
await kv.delete("a");
2236-
await kv.purge("a", { ttl: "1s" });
2237-
await delay(2000);
2238-
const e = await kv.get("a");
2239-
console.log(e);
2236+
let e = await kv.get("a");
2237+
assertEquals(e?.operation, "DEL");
2238+
await kv.purge("a", { ttl: "2s" });
2239+
e = await kv.get("a");
22402240
assertEquals(e?.operation, "PURGE");
2241+
2242+
await delay(2500);
2243+
e = await kv.get("a");
2244+
assertEquals(e, null);
22412245
await cleanup(ns, nc);
22422246
});
22432247

@@ -2279,8 +2283,7 @@ Deno.test("kv - entries ttl", async () => {
22792283
}
22802284

22812285
const end = Date.now() - start;
2282-
// 2s for the purge, and the 2s for the markerTTL
2283-
assertBetween(end, 4000, 4500);
2286+
assert(end > 2000);
22842287

22852288
await cleanup(ns, nc);
22862289
});

0 commit comments

Comments
 (0)