run_tests:
  stage: test
  image: cloudron/base:4.2.0@sha256:46da2fffb36353ef714f97ae8e962bd2c212ca091108d768ba473078319a47f4
  services:
    - name: mysql:8.0
      alias: mysql
  variables:
    MYSQL_ROOT_PASSWORD: password
    MYSQL_DATABASE: box
    BOX_ENV: ci
    DATABASE_URL: mysql://root:password@mysql/box
  script:
    - echo "Running tests..."
    - mysql -hmysql -uroot -ppassword -e "ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';"
    - mysql -hmysql -uroot -ppassword -e "CREATE DATABASE IF NOT EXISTS box"
    - npm install
    - node_modules/.bin/db-migrate up
    - ln -s /usr/local/node-18.18.0/bin/node /usr/bin/node
    - node_modules/.bin/mocha --no-timeouts --bail src/test/tokens-test.js
    - echo "Done!"

stages:
  - test

