-
Notifications
You must be signed in to change notification settings - Fork 5
/
_test_util.ts
31 lines (26 loc) · 932 Bytes
/
_test_util.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { assert } from "jsr:@std/assert@~1/assert";
export { concat } from "jsr:@std/bytes@~1/concat";
export { delay } from "jsr:@std/async@~1/delay";
export { assert } from "jsr:@std/assert@~1/assert";
export { assertEquals } from "jsr:@std/assert@~1/equals";
export { assertNotEquals } from "jsr:@std/assert@~1/not-equals";
export { assertRejects } from "jsr:@std/assert@~1/rejects";
export { assertStrictEquals } from "jsr:@std/assert@~1/strict-equals";
export { timingSafeEqual } from "jsr:@std/crypto@~1/timing-safe-equal";
let kv: { close(): void } | undefined;
let path: string | undefined;
export async function getPath() {
return path = `${await Deno.makeTempDir()}/test.db`;
}
export async function setup() {
return kv = await Deno.openKv(await getPath());
}
export function cleanup() {
assert(path);
return Deno.remove(path);
}
export function teardown() {
assert(kv);
kv.close();
return cleanup();
}