2024-01-01 14:58:21 -05:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2023-11-10 16:29:09 -05:00
|
|
|
import { assert, assertEquals, assertNotEquals } from "./test_util.ts";
|
2023-08-29 14:24:44 -04:00
|
|
|
|
|
|
|
Deno.test({
|
|
|
|
sanitizeOps: false,
|
|
|
|
sanitizeResources: false,
|
|
|
|
}, async function queueTestNoDbClose() {
|
|
|
|
const db: Deno.Kv = await Deno.openKv(":memory:");
|
2023-11-10 16:29:09 -05:00
|
|
|
const { promise, resolve } = Promise.withResolvers<void>();
|
2023-08-29 14:24:44 -04:00
|
|
|
let dequeuedMessage: unknown = null;
|
|
|
|
db.listenQueue((msg) => {
|
|
|
|
dequeuedMessage = msg;
|
2023-11-10 16:29:09 -05:00
|
|
|
resolve();
|
2023-08-29 14:24:44 -04:00
|
|
|
});
|
|
|
|
const res = await db.enqueue("test");
|
|
|
|
assert(res.ok);
|
|
|
|
assertNotEquals(res.versionstamp, null);
|
|
|
|
await promise;
|
|
|
|
assertEquals(dequeuedMessage, "test");
|
|
|
|
});
|