Skip to content

Commit 0c37ea8

Browse files
committed
stubbing out api tests
1 parent 6dd2def commit 0c37ea8

File tree

10 files changed

+324
-1246
lines changed

10 files changed

+324
-1246
lines changed

.env-temp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DOMAIN=localhost
2+
PORT=5337
3+
MONGODB_URI=mongodb://localhost:27017/rsscloud

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM node:12 AS base
2+
3+
# Dockerize is needed to sync containers startup
4+
ENV DOCKERIZE_VERSION v0.6.1
5+
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
6+
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
7+
&& rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz
8+
9+
RUN mkdir -p ~/app
10+
11+
WORKDIR ~/app
12+
13+
COPY package.json .
14+
COPY package-lock.json .
15+
16+
FROM base AS dependencies
17+
18+
RUN npm ci
19+
20+
FROM dependencies AS runtime
21+
22+
COPY . .

bin/import-data.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ async function doImport() {
88
if (fs.existsSync('./data/data.json')) {
99
const data = JSON.parse(fs.readFileSync('./data/data.json', 'utf8'));
1010

11+
await db.createCollection('events');
12+
await db.createCollection('resources');
13+
1114
await db.collection('resources').bulkWrite(
1215
Object.keys(data.resources).map(id => {
1316
return {
@@ -20,6 +23,8 @@ async function doImport() {
2023
})
2124
);
2225

26+
await db.createCollection('subscriptions');
27+
2328
await db.collection('subscriptions').bulkWrite(
2429
Object.keys(data.subscriptions).map(id => {
2530
const subscriptions = {

docker-compose.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: '3.1'
2+
3+
services:
4+
5+
mongodb:
6+
image: mongo
7+
expose:
8+
- 27017
9+
10+
rsscloud:
11+
build: .
12+
image: rsscloud
13+
command: node --use_strict app.js
14+
environment:
15+
DOMAIN: rsscloud
16+
PORT: 5337
17+
MONGODB_URI: mongodb://mongodb:27017/rsscloud
18+
expose:
19+
- 5337
20+
depends_on:
21+
- mongodb
22+
23+
rsscloud-tests:
24+
image: rsscloud
25+
command: dockerize -wait tcp://mongodb:27017 -wait http://rsscloud:5337 -timeout 10s bash -c "node bin/import-data.js && npm test"
26+
environment:
27+
APP_URL: http://rsscloud:5337
28+
DOMAIN: localhost
29+
PORT: 5337
30+
MONGODB_URI: mongodb://mongodb:27017/rsscloud
31+
expose:
32+
- 8002
33+
depends_on:
34+
- mongodb
35+
- rsscloud

0 commit comments

Comments
 (0)