-
Notifications
You must be signed in to change notification settings - Fork 13
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f85433c
Setup test database for running database tests
cychu42 477bd5e
* Add SQL setup file for database
cychu42 a6c9ad9
* Update /dev-secrets/DATABASE_URL
cychu42 4c6f481
* Keep old starchart db setup
cychu42 ec3e0db
* Put test db connection string in test scripts
cychu42 ef56be3
* Add instructon in CONTRIBUTION.md
cychu42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,8 @@ $ npm run db:studio | |
|
||
> **Note** `npm run build` needs to be executed the first time running the project. As it generates a `build/server.js` script that `npm run dev` depends on. Subsequent times, only `npm run dev` is needed to run the app in development mode. | ||
|
||
> **Note** If you are running test scripts for the first time, change `DATABASE_URL` in `.env` to `DATABASE_URL="mysql://starchart:[email protected]:3306/starchart"` and run `npm run setup` to setup the test database. You can change this back afterward. | ||
|
||
## SAML Accounts to use in Dev | ||
|
||
Our IDP is configured with a few accounts that exist for testing, the usernames and passwords to use are as follows: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- create test databases | ||
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'@'%'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,10 +22,10 @@ | |
"setup": "run-s db:generate db:push db:seed", | ||
"start": "cross-env NODE_ENV=production node ./build/server.js", | ||
"start:e2e": "cross-env NODE_ENV=test node --require dotenv/config ./build/server.js", | ||
"test": "cross-env SECRETS_OVERRIDE=1 NODE_OPTIONS=--require=dotenv/config vitest", | ||
"test:e2e:dev": "cross-env PORT=8080 start-server-and-test dev http://localhost:8080 \"playwright test\"", | ||
"test": "cross-env SECRETS_OVERRIDE=1 DATABASE_URL='mysql://root:[email protected]:3306/starchart_test' NODE_OPTIONS=--require=dotenv/config vitest", | ||
"test:e2e:dev": "cross-env PORT=8080 DATABASE_URL='mysql://root:[email protected]:3306/starchart_test' start-server-and-test dev http://localhost:8080 \"playwright test\"", | ||
"pretest:e2e:run": "cross-env NODE_ENV=test SECRETS_OVERRIDE=1 run-s build", | ||
"test:e2e:run": "cross-env SECRETS_OVERRIDE=1 PORT=8080 start-server-and-test start:e2e http://localhost:8080 \"playwright test\"", | ||
"test:e2e:run": "cross-env SECRETS_OVERRIDE=1 PORT=8080 DATABASE_URL='mysql://root:[email protected]:3306/starchart_test' start-server-and-test start:e2e http://localhost:8080 \"playwright test\"", | ||
"typecheck": "tsc", | ||
"validate": "run-p \"test -- --run\" lint typecheck test:e2e:run", | ||
"prepare": "husky install" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to be done in this PR, but would it be worth to add a new
setup:test
script to do this instead?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps. If someone can write a script that has a command to parse the file to change the variable, runs
npm run setup
, then changes it back.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I think we can simply copy the
setup
command tosetup:test
, and override the value forDATABASE_URL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Eakam1007 do you want to file an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I might just create a PR for this today. Seems simple enough (unless I am missing something)