Skip to content

Commit

Permalink
Add common tests. Closes #12
Browse files Browse the repository at this point in the history
Update travis.
  • Loading branch information
AlekNS committed Feb 14, 2018
1 parent e936e13 commit 6d54e82
Show file tree
Hide file tree
Showing 75 changed files with 2,030 additions and 295 deletions.
2 changes: 0 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
.git
node_modules
npm-debug.log
coverage
.nyc_output
dist
.env
storage
2 changes: 1 addition & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ RPC_ADDRESS=https://ropsten.infura.io/ujGcHij7xZIyz2afx4h2

WEB3_RESTORE_START_BLOCK=

ERC20_TOKEN_ABI_FILEPATH=test/abi/StandardToken.abi
ERC20_TOKEN_ABI_FILEPATH=contracts/erc20.abi
2 changes: 1 addition & 1 deletion .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"lines": 80,
"statements": 80,
"functions": 80,
"branches": 68,
"branches": 58,
"include": [
"**/*.ts"
],
Expand Down
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
language: node_js
node_js: '8.6'
sudo: required
services:
- docker
cache:
directories:
- node_modules
- $HOME/.npm
install:
- npm install
- docker-compose -f docker-compose.test.yml build --no-cache api
script:
- docker-compose -f docker-compose.test.yml run --rm api sh -c "npm run test:cover"
after_success:
- npm run build
- chmod ugo+x ./build.sh
- export TAG=`if [ "$TRAVIS_BRANCH" == "master" ]; then echo "prod"; elif [ "$TRAVIS_BRANCH"
== "dev" ]; then echo "stage"; else echo "dev-$(git rev-parse --short HEAD)"; fi`
Expand Down
7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ FROM mhart/alpine-node:8.6
WORKDIR /usr/src/app
ADD . /usr/src/app

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

CMD npm run serve
9 changes: 6 additions & 3 deletions Dockerfile.local
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM mhart/alpine-node:8.9.1

RUN apk update && apk upgrade && apk add git && apk add python && apk add make && apk add g++
WORKDIR /usr/src/app

RUN apk add --update --no-cache git python make g++ && \
npm install && \
apk del --purge git python make g++

VOLUME /usr/src/app
EXPOSE 3000
EXPOSE 4000
WORKDIR /usr/src/app
6 changes: 2 additions & 4 deletions Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ FROM mhart/alpine-node:8.6
WORKDIR /usr/src/app
ADD . /usr/src/app

RUN apk add --update --no-cache git python make g++ && \
npm install && \
apk del --purge git python make g++
RUN npm install

CMD npm start
CMD npm test
57 changes: 1 addition & 56 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,61 +8,21 @@ services:
image: jincort/backend-token-wallets:test
networks:
backendTokenWalletsTests:
aliases:
- api
build:
context: ./
dockerfile: Dockerfile.test
env_file:
- .env.test
command: >
sh -c '
apk add --update --no-cache curl &&
n=1; while [ -z "`nc -z auth 3000 && echo 1`" ] && [ "$$n" != "30" ]; do sleep 1; n=`expr $$n + 1`; echo "Wait auth $$n"; done &&
curl auth:3000/tenant -H "Accept: application/json" -H "Content-Type: application/json" \
-d "{\"email\":\"test@test.com\",\"password\":\"aA1qwerty\"}" ;
export AUTH_ACCESS_JWT=`curl auth:3000/tenant/login -H "Accept: application/json" -H "Content-Type: application/json" \
-d "{\"email\":\"test@test.com\",\"password\":\"aA1qwerty\"}" | grep -oE "accessToken\":\"[^\"]+" | cut -d\" -f3` ;
npm test
npm run test:cover
'
volumes:
- ./src/:/usr/src/app/src:ro
- ./test/:/usr/src/app/test:ro
links:
- mongo
- redis
- auth
- verify
- nsqd

auth:
image: jincort/backend-auth:production
networks:
backendTokenWalletsTests:
aliases:
- auth
environment:
REDIS_HOST: redis
REDIS_PORT: 6379
FORCE_HTTPS: disabled
JWT_KEY: zd003d435e74b9150aa5573cb73ddfbe1
THROTTLER_WHITE_LIST: "127.0.0.1"
TENANT_WHITE_LIST: "*"
THROTTLER_MAX: "10000"
links:
- redis

verify:
image: jincort/backend-verify:stage
networks:
backendTokenWalletsTests:
environment:
REDIS_URL: 'redis://redis:6379'
THROTTLER_WHITE_LIST: "127.0.0.1"
THROTTLER_MAX: "10000"
links:
- redis
- auth

redis:
image: jincort/backend-redis:latest
Expand All @@ -77,18 +37,3 @@ services:
backendTokenWalletsTests:
tmpfs:
- /data/db

nsqlookupd:
image: nsqio/nsq:v1.0.0-compat
command: /nsqlookupd
networks:
backendTokenWalletsTests:

nsqd:
image: nsqio/nsq:v1.0.0-compat
networks:
backendTokenWalletsTests:
volumes:
- /data
command: >
/nsqd -max-deflate-level=6 -deflate -max-msg-size=5048576 --data-path=/data --lookupd-tcp-address=nsqlookupd:4160
Loading

0 comments on commit 6d54e82

Please sign in to comment.