-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
server_test.ts
64 lines (58 loc) · 1.5 KB
/
server_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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { Fastro } from "../mod.ts";
import { assertEquals } from "../deps.ts";
const { test } = Deno;
const port = 3000;
const base = `http://localhost:${port}`;
Deno.env.set("DENO_ENV", "test");
test({
name: "BASIC GET",
async fn() {
const server = new Fastro();
server.listen();
const result = await fetch(`${base}/hello`);
const text = await result.text();
assertEquals(text, "setup complete");
server.close();
},
sanitizeResources: false,
sanitizeOps: false,
});
test({
name: "PREFIX",
async fn() {
const server = new Fastro({ prefix: "api" });
server.listen();
const result = await fetch(`${base}/api/hello`);
const text = await result.text();
assertEquals(text, "setup complete");
server.close();
},
sanitizeResources: false,
sanitizeOps: false,
});
test({
name: "SERVICE DIRECTORY",
async fn() {
const server = new Fastro({ serviceDir: "services/hello/v1" });
server.listen({ port });
const result = await fetch(`${base}/hello`);
const text = await result.text();
assertEquals(text, "hello v1");
server.close();
},
sanitizeResources: false,
sanitizeOps: false,
});
test({
name: "SERVICE DIRECTORY 2",
async fn() {
const server = new Fastro({ serviceDir: "services/hello/v2" });
server.listen({ port });
const result = await fetch(`${base}/hello`);
const text = await result.text();
assertEquals(text, "hello v2");
server.close();
},
sanitizeResources: false,
sanitizeOps: false,
});