Skip to content

Commit 0c93b16

Browse files
committed
Add common tests. Closes #12
Update travis.
1 parent e936e13 commit 0c93b16

File tree

74 files changed

+2029
-294
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+2029
-294
lines changed

.env.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ RPC_ADDRESS=https://ropsten.infura.io/ujGcHij7xZIyz2afx4h2
3737

3838
WEB3_RESTORE_START_BLOCK=
3939

40-
ERC20_TOKEN_ABI_FILEPATH=test/abi/StandardToken.abi
40+
ERC20_TOKEN_ABI_FILEPATH=contracts/erc20.abi

.nycrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"lines": 80,
33
"statements": 80,
44
"functions": 80,
5-
"branches": 68,
5+
"branches": 58,
66
"include": [
77
"**/*.ts"
88
],

.travis.yml

+12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1+
language: node_js
2+
node_js: '8.6'
13
sudo: required
24
services:
35
- docker
6+
cache:
7+
directories:
8+
- node_modules
9+
- $HOME/.npm
10+
install:
11+
- npm install
12+
- docker-compose build --no-cache
413
script:
14+
- docker-compose run --rm api sh -c "npm test:cover"
15+
after_success:
16+
- npm run build
517
- chmod ugo+x ./build.sh
618
- export TAG=`if [ "$TRAVIS_BRANCH" == "master" ]; then echo "prod"; elif [ "$TRAVIS_BRANCH"
719
== "dev" ]; then echo "stage"; else echo "dev-$(git rev-parse --short HEAD)"; fi`

Dockerfile

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ FROM mhart/alpine-node:8.6
33
WORKDIR /usr/src/app
44
ADD . /usr/src/app
55

6-
RUN apk add --update --no-cache git python make g++ && \
7-
npm install && \
8-
npm run build && \
9-
npm prune --production && \
10-
apk del --purge git python make g++ && \
6+
RUN npm prune --production && \
7+
npm install --production && \
118
rm -rf ./src ./test /root/.npm/_cacache
129

1310
CMD npm run serve

Dockerfile.local

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
FROM mhart/alpine-node:8.9.1
22

3-
RUN apk update && apk upgrade && apk add git && apk add python && apk add make && apk add g++
3+
WORKDIR /usr/src/app
4+
5+
RUN apk add --update --no-cache git python make g++ && \
6+
npm install && \
7+
apk del --purge git python make g++
8+
49
VOLUME /usr/src/app
510
EXPOSE 3000
6-
EXPOSE 4000
7-
WORKDIR /usr/src/app

Dockerfile.test

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,4 @@ FROM mhart/alpine-node:8.6
33
WORKDIR /usr/src/app
44
ADD . /usr/src/app
55

6-
RUN apk add --update --no-cache git python make g++ && \
7-
npm install && \
8-
apk del --purge git python make g++
9-
10-
CMD npm start
6+
CMD npm test

docker-compose.test.yml

+1-56
Original file line numberDiff line numberDiff line change
@@ -8,61 +8,21 @@ services:
88
image: jincort/backend-token-wallets:test
99
networks:
1010
backendTokenWalletsTests:
11-
aliases:
12-
- api
1311
build:
1412
context: ./
1513
dockerfile: Dockerfile.test
1614
env_file:
1715
- .env.test
1816
command: >
1917
sh -c '
20-
apk add --update --no-cache curl &&
21-
n=1; while [ -z "`nc -z auth 3000 && echo 1`" ] && [ "$$n" != "30" ]; do sleep 1; n=`expr $$n + 1`; echo "Wait auth $$n"; done &&
22-
curl auth:3000/tenant -H "Accept: application/json" -H "Content-Type: application/json" \
23-
-d "{\"email\":\"test@test.com\",\"password\":\"aA1qwerty\"}" ;
24-
export AUTH_ACCESS_JWT=`curl auth:3000/tenant/# -H "Accept: application/json" -H "Content-Type: application/json" \
25-
-d "{\"email\":\"test@test.com\",\"password\":\"aA1qwerty\"}" | grep -oE "accessToken\":\"[^\"]+" | cut -d\" -f3` ;
26-
npm test
18+
npm run test:cover
2719
'
2820
volumes:
2921
- ./src/:/usr/src/app/src:ro
3022
- ./test/:/usr/src/app/test:ro
3123
links:
3224
- mongo
3325
- redis
34-
- auth
35-
- verify
36-
- nsqd
37-
38-
auth:
39-
image: jincort/backend-auth:production
40-
networks:
41-
backendTokenWalletsTests:
42-
aliases:
43-
- auth
44-
environment:
45-
REDIS_HOST: redis
46-
REDIS_PORT: 6379
47-
FORCE_HTTPS: disabled
48-
JWT_KEY: zd003d435e74b9150aa5573cb73ddfbe1
49-
THROTTLER_WHITE_LIST: "127.0.0.1"
50-
TENANT_WHITE_LIST: "*"
51-
THROTTLER_MAX: "10000"
52-
links:
53-
- redis
54-
55-
verify:
56-
image: jincort/backend-verify:stage
57-
networks:
58-
backendTokenWalletsTests:
59-
environment:
60-
REDIS_URL: 'redis://redis:6379'
61-
THROTTLER_WHITE_LIST: "127.0.0.1"
62-
THROTTLER_MAX: "10000"
63-
links:
64-
- redis
65-
- auth
6626

6727
redis:
6828
image: jincort/backend-redis:latest
@@ -77,18 +37,3 @@ services:
7737
backendTokenWalletsTests:
7838
tmpfs:
7939
- /data/db
80-
81-
nsqlookupd:
82-
image: nsqio/nsq:v1.0.0-compat
83-
command: /nsqlookupd
84-
networks:
85-
backendTokenWalletsTests:
86-
87-
nsqd:
88-
image: nsqio/nsq:v1.0.0-compat
89-
networks:
90-
backendTokenWalletsTests:
91-
volumes:
92-
- /data
93-
command: >
94-
/nsqd -max-deflate-level=6 -deflate -max-msg-size=5048576 --data-path=/data --lookupd-tcp-address=nsqlookupd:4160

0 commit comments

Comments
 (0)