Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup test database for running tests for database #350

Merged
merged 6 commits into from
Mar 18, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/.vscode
/img
/e2e/
/mysql-data
/mysql/data
/node_modules
/playwright-report
/test
Expand Down
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# NOTE: this value is also mirrored in dev-secrets/DATABASE_URL.
# We set it here for Prisma scripts to work, which expect it
# in the env, but at runtime we read it as a secret in docker swarm.
DATABASE_URL="mysql://starchart:starchart_password@127.0.0.1:3306/starchart"
DATABASE_URL="mysql://root:root_password@127.0.0.1:3306/starchart"
cychu42 marked this conversation as resolved.
Show resolved Hide resolved

# Connect to Redis container locally
REDIS_URL=redis://localhost:6379
Expand Down
33 changes: 33 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Connect to MySQL Docker container locally
# NOTE: this value is also mirrored in dev-secrets/DATABASE_URL.
# We set it here for Prisma scripts to work, which expect it
# in the env, but at runtime we read it as a secret in docker swarm.
DATABASE_URL="mysql://root:[email protected]:3306/starchart_test"

# Connect to Redis container locally
REDIS_URL=redis://localhost:6379

# Let's encrypt directory URL (the server we request the cert from)
# Staging: 'https://acme-staging-v02.api.letsencrypt.org/directory'
# Production 'https://acme-v02.api.letsencrypt.org/directory'
# Local development / testing docker container 'https://127.0.0.1:14000/dir'
LETS_ENCRYPT_DIRECTORY_URL="https://127.0.0.1:14000/dir"

# https://letsencrypt.org/docs/expiration-emails/
LETS_ENCRYPT_ACCOUNT_EMAIL="[email protected]"

PORT=8080

# One of: trace, debug, info, warn, error, fatal, silent
LOG_LEVEL=debug

# Notifications Email Config
NOTIFICATIONS_EMAIL_USER="[email protected]"
SMTP_PORT=1025

# SSO Config
HOSTNAME=http://localhost:8080
# The SimpleSAML IDP's XML metadata
SAML_IDP_METADATA_PATH=config/idp-metadata-dev.xml
# Our apps's SP Entity ID, which is also the URL to our metadata.
SAML_ENTITY_ID=http://host.docker.internal:8080/sp
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/node_modules
/build
/public/build
/mysql-data
/mysql/data
/redis-data
/img
/dev-secrets
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ node_modules
.env

/redis-data
/mysql-data
/mysql/data
/test-results/
/playwright-report/
/playwright/.cache/
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ node_modules
/public/build
.env
/redis-data
/mysql-data
/mysql/data
/img
/playwright-report/
/dev-secrets
Expand Down
9 changes: 4 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ services:
# Only for dev
- 3306:3306
volumes:
# Persist data to ./mysql-data. Remove if you want to clear the db.
- ./mysql-data:/var/lib/mysql
# Persist data to ./mysql/data. Remove if you want to clear the db.
- ./mysql/data:/var/lib/mysql
cychu42 marked this conversation as resolved.
Show resolved Hide resolved
# Locate SQL file to setup database
- ./mysql/init:/docker-entrypoint-initdb.d
cychu42 marked this conversation as resolved.
Show resolved Hide resolved
environment:
MYSQL_DATABASE: starchart
MYSQL_USER: starchart
MYSQL_PASSWORD: starchart_password
MYSQL_ROOT_PASSWORD: root_password

redis:
Expand Down
7 changes: 7 additions & 0 deletions mysql/init/01-databases.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- create regular and test databases
cychu42 marked this conversation as resolved.
Show resolved Hide resolved
CREATE DATABASE IF NOT EXISTS `startchart`;
CREATE DATABASE IF NOT EXISTS `starchart_test`;

-- create root user and grant rights
CREATE USER 'root'@'localhost' IDENTIFIED BY 'root_password';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';