Skip to content

Commit 372f0d7

Browse files
committed
Add docker compose test
1 parent 17a7fea commit 372f0d7

File tree

6 files changed

+20
-191
lines changed

6 files changed

+20
-191
lines changed

test.json

Lines changed: 0 additions & 184 deletions
This file was deleted.

test/Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
FROM hayd/alpine-deno:1.0.0
1+
FROM hayd/ubuntu-deno:1.0.2
22

33

44
WORKDIR /app
55

66
# Prefer not to run as root.
7-
USER deno
7+
RUN apt-get -qq update \
8+
&& apt-get install -y jq curl
89

10+
USER deno
911
# Cache the dependencies as a layer (the following two steps are re-run only when deps.ts is modified).
1012
# Ideally fetch deps.ts will download and compile _all_ external files used in main.ts.
1113
COPY deps.ts .
@@ -15,5 +17,8 @@ RUN deno cache deps.ts
1517
ADD . .
1618
# Compile the main app so that it doesn't need to be compiled each startup/entry.
1719
RUN deno cache main.ts
20+
RUN deno cache test.ts
21+
22+
1823

1924
CMD ["run","--allow-net", "--allow-env", "main.ts"]

test/docker-compose.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
version: "3.7"
22
services:
3-
deno:
3+
api-test:
44
build: .
55
image: api-test
66
ports:
77
- "3000:3000"
88
volumes:
99
- ./:/app
10+
- ../api-test.sh:/app/api-test.sh
11+
12+
test:
13+
build: .
14+
image: api-test
15+
command: test --allow-run test.ts
16+
volumes:
17+
- ./:/app
18+
- ../api-test.sh:/app/api-test.sh

test/main.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ const postBook = async (ctx: RouterContext<RouteParams>) => {
4949
});
5050
const body: any = JSON.parse(result.value)
5151
const book: IBook | undefined = searchBookById(body.id)
52-
console.log(body)
53-
if (!book) {
52+
if (!book) {
5453
response.status = 200
5554
response.body = body
5655
} else {

test/test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
}
2626
}
2727
},
28-
"url": "localhost:3000",
28+
"url": "api-test:3000",
2929
"header": {
3030
"Content-Type": "application/javascript"
3131
}

test/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect } from "https://deno.land/x/expect/mod.ts";
33
async function run(testCase: string) {
44
const cmd = Deno.run({
55
cmd: [
6-
"../api-test.sh",
6+
"./api-test.sh",
77
"-f",
88
"test.json",
99
"run",

0 commit comments

Comments
 (0)