Fix database closed multiple times.

utt part support Ctrl + C
This commit is contained in:
2023-05-23 10:50:56 +08:00
parent 144797f246
commit 5c9712a02c
6 changed files with 69 additions and 12 deletions

View File

@@ -1,6 +1,12 @@
import { assertEquals } from "std/testing/asserts.ts";
import { check_running } from "./pid_check.ts";
import { asyncFilter, promiseState, PromiseStatus, sleep } from "./utils.ts";
import {
asyncFilter,
asyncForEach,
promiseState,
PromiseStatus,
sleep,
} from "./utils.ts";
Deno.test("promiseState_test", async () => {
const p1 = new Promise((res) => setTimeout(() => res(100), 100));
@@ -42,3 +48,12 @@ Deno.test("asyncFilter_test", async () => {
assertEquals(v, e);
await Promise.allSettled(e);
});
Deno.test("asyncForEach", async () => {
const e = [new Promise<number>((res) => setTimeout(() => res(100), 100))];
const t = { test: 2 };
await asyncForEach(e, async function (e) {
assertEquals(this, t);
await e;
}, t);
});