Skip to content

Commit

Permalink
Setup test database for running database tests
Browse files Browse the repository at this point in the history
* Add .env.test
  • Loading branch information
cychu42 committed Mar 15, 2023
1 parent 03f8931 commit f85433c
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/img
/e2e/
/mysql-data
/mysql-data-test
/node_modules
/playwright-report
/test
Expand Down
20 changes: 20 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Connect to MySQL Docker container locally
DATABASE_URL="mysql://starchart:starchart_password@localhost:3307/starchart_test"

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

# Used to compute hash against the session IDs. Should be long, random.
SESSION_SECRET="super-duper-s3cret"

# 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

# Nodemailer config
NOTIFICATIONS_EMAIL_USER="[email protected]"
MAILHOG_SMTP_PORT=1025
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/build
/public/build
/mysql-data
/mysql-data-test
/redis-data
/img
/dev-secrets
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules

/redis-data
/mysql-data
/mysql-data-test
/test-results/
/playwright-report/
/playwright/.cache/
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ node_modules
.env
/redis-data
/mysql-data
/mysql-data-test
/img
/playwright-report/
/dev-secrets
Expand Down
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ services:
MYSQL_PASSWORD: starchart_password
MYSQL_ROOT_PASSWORD: root_password

test_database:
image: mysql:8
container_name: test_database
ports:
# Only for dev to run tests in a database
- 3307:3306
volumes:
# Persist data to ./mysql-data-test. Remove if you want to clear the db.
- ./mysql-data-test:/var/lib/mysql
environment:
MYSQL_DATABASE: starchart_test
MYSQL_USER: starchart
MYSQL_PASSWORD: starchart_password
MYSQL_ROOT_PASSWORD: root_password

redis:
image: redis:7.0.8-alpine3.17
container_name: redis
Expand Down

0 comments on commit f85433c

Please sign in to comment.