-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.ts
45 lines (38 loc) · 973 Bytes
/
test.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { assert } from "@std/assert";
import { env } from "./core/env.ts";
// KV Databaseの初期化
import "./db/init.ts";
// Disable server logs
console.log = (_) => {};
console.error = (_) => {};
// Run server
import "./server.ts";
// Wait for server to start
const port = env.PORT;
await fetch(`http://localhost:${port}/version`);
Deno.test({
name: "Test",
sanitizeOps: false,
sanitizeResources: false,
fn: async () => {
const cmd = new Deno.Command(Deno.execPath(), {
args: [
"test",
"--allow-read",
"--allow-env",
"--allow-net",
"--ignore=test.ts",
"--unstable-kv",
...Deno.args,
],
stdout: "piped",
stderr: "piped",
});
const child = cmd.spawn();
child.stdout.pipeTo(Deno.stdout.writable);
child.stderr.pipeTo(Deno.stderr.writable);
const status = await child.status;
assert(status.success);
setTimeout(() => Deno.exit(0), 100);
},
});