3

I would like to create a database with a dump (that I have locally) to perform unit-test which needs to have a database ready with the good structure. I am using gitlab runner, and here is my .gitlab-ci.yml file :



stages:
  - build
  - test

services:
  - postgres:9.6.19

variables:
  POSTGRES_DB: test
  POSTGRES_USER: admin
  POSTGRES_PASSWORD: admin
  POSTGRES_HOST_AUTH_METHOD: trust

connect:
  stage: build
  image: postgres
  script:
    - export PGPASSWORD=$POSTGRES_PASSWORD
    - psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -f $CI_PROJECT_DIR/spec/db/dump_test.sql
    
all_tests:
  stage: test
  script:
   - npm install
   - npm test

When the test stage runs, the database connection is note done, and functions which are using the connection failed. How to handle the connection ?

thanks by advance and good week end guys (even if you continue coding like me ;) )

Carlos
  • 119
  • 10

0 Answers0