@@ -79,17 +79,20 @@ endif
7979.PHONY : e2e-tests
8080e2e-tests : # # Start end2end tests
8181 @make up &
82-
83- @# wait until server is ready and the connection to the db is ready
84- @- while ! curl -s -f -LI http://localhost:8080/health >> /dev/null; do echo "waiting until server is ready for tests..." && sleep 3; done
85-
86- @set -a && source env.local.test && set +a && npx jest ./tests/api_e2e --verbose true || true
87-
88- @docker compose down
89-
90- @echo "Done - Some important information for debugging:"
91- @echo " - If the tests fail, consider to refresh the db by running 'make down-db' first"
92- @echo " - To have data for spotify, apple, and anchor, use podcast_id 3 for the tests"
82+ @UP_PID=$$ ! ; \
83+ echo " Starting services (PID: $$ UP_PID)..." ; \
84+ trap ' docker compose down; kill $$UP_PID 2>/dev/null || true' EXIT; \
85+ while ! curl -s -f -LI http://localhost:8080/health >> /dev/null; do \
86+ echo " waiting until server is ready for tests..." && sleep 3; \
87+ done ; \
88+ echo " Server is ready, running tests..." ; \
89+ set -a && source env.local.test && set +a && npx jest ./tests/api_e2e --verbose true ; \
90+ TEST_EXIT_CODE=$$? ; \
91+ docker compose down; \
92+ echo " Done - Some important information for debugging:" ; \
93+ echo " - If the tests fail, consider to refresh the db by running 'make down' first" ; \
94+ echo " - To have data for spotify, apple, and anchor, use podcast_id 3 for the tests" ; \
95+ exit $$ TEST_EXIT_CODE
9396
9497.PHONY : status
9598status : # # Send status request
@@ -111,7 +114,15 @@ send-api-req-prod: ## Send request to production
111114db-shell : # # Opens the mysql shell inside the db container
112115 docker compose exec db bash -c ' mysql -uopenpodcast -popenpodcast openpodcast'
113116
114- .PHONY : test-one-e2e-%
115- test-one-e2e-% : # # Run end2end tests for a specific test case
116- @echo " Running end2end test for: $* "
117- npx jest ./tests/api_e2e --verbose true --testNamePattern=" $* "
117+ .PHONY : db-init-auth
118+ db-init-auth : # # Initialize the auth db after api is up
119+ # creates the auth schema
120+ docker cp ./db_schema/auth.sql $$(docker compose ps -q db ) :/tmp/auth.sql
121+ docker compose exec db bash -c ' mysql -uopenpodcast -popenpodcast openpodcast_auth < /tmp/auth.sql'
122+
123+ # creates some dummy auth data
124+ docker cp ./db_auth_data.sql $$(docker compose ps -q db ) :/tmp/auth_data.sql
125+ docker compose exec db bash -c ' mysql -uopenpodcast -popenpodcast openpodcast_auth < /tmp/auth_data.sql'
126+ docker cp ./db_auth_data.sql api-db-1:/tmp/auth_data.sql
127+ docker compose exec db bash -c ' mysql -uopenpodcast -popenpodcast openpodcast_auth < /tmp/auth_data.sql'
128+
0 commit comments