From 3ed190bfdedcc1e0aece23762ed75688e1f8b311 Mon Sep 17 00:00:00 2001 From: dbroqua Date: Tue, 18 Feb 2020 13:38:40 +0100 Subject: [PATCH] Updated docker images and tests suites --- config/config.json | 3 ++- docker-compose.yml | 24 ++++-------------------- package.json | 9 ++++++++- test.sh | 5 +++++ 4 files changed, 19 insertions(+), 22 deletions(-) create mode 100755 test.sh diff --git a/config/config.json b/config/config.json index a8beb41..75fbbd5 100644 --- a/config/config.json +++ b/config/config.json @@ -3,7 +3,8 @@ "username": "postgres", "password": "postgres", "database": "test", - "host": "sequelize-middleware-db", + "host": "127.0.0.1", + "port": "5666", "dialect": "postgres", "seederStorage": "sequelize" }, diff --git a/docker-compose.yml b/docker-compose.yml index 456f527..debf297 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,33 +1,17 @@ version: "2" services: - sequelize-middleware: - image: "node:latest" - user: "node" - working_dir: /home/node/app - command: > - bash -c "yarn install && - ./node_modules/.bin/sequelize db:seed:undo:all && - ./node_modules/.bin/sequelize db:migrate:undo:all && - ./node_modules/.bin/sequelize db:migrate && - ./node_modules/.bin/sequelize db:seed:all && - yarn test --ci --coverage" - volumes: - - ./:/home/node/app - - /home/node/node_modules - ports: - - "3666:4000" - depends_on: - - sequelize-middleware-db - environment: - NODE_ENV: "test" sequelize-middleware-db: image: postgres:latest environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: test + restart: always + ports: + - 127.0.0.1:5666:5432 sequelize-middleware-adminer: image: adminer + restart: always ports: - 127.0.0.1:8666:8080 diff --git a/package.json b/package.json index a97e05e..efbec3a 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,15 @@ "description": "Middleware to automate tasks with Sequelize", "main": "index.js", "scripts": { + "undo:seed": "./node_modules/.bin/sequelize db:seed:undo:all", + "undo:migrate": "./node_modules/.bin/sequelize db:migrate:undo:all", + "undo:all": "yarn undo:seed && yarn undo:migrate", + "do:migrate": "./node_modules/.bin/sequelize db:migrate", + "do:seed": "./node_modules/.bin/sequelize db:seed:all", + "do:all": "yarn do:migrate && yarn do:seed", + "pretest": "yarn undo:all && yarn do:all", "lint": "./node_modules/.bin/eslint . --fix", - "test": "jest --forceExit --detectOpenHandles --maxWorkers=10" + "test": "jest --forceExit --detectOpenHandles --maxWorkers=10 --ci --coverage" }, "repository": { "type": "git", diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..bdecde2 --- /dev/null +++ b/test.sh @@ -0,0 +1,5 @@ +#! /bin/bash + +export NODE_ENV="test"; + +yarn test