this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Added make commands to switch to test db during playwright tests (#3326)

* Added make commands to switch to test db during playwright tests

* create test db on first run

authored by

Shivank Kacker and committed by
GitHub
6e7acdf6 a0bfe6dd

+23
+23
Makefile
··· 94 94 ruff-docker: 95 95 docker exec care bash -c "ruff check --fix $(shell git diff --name-only --staged | grep -E '\.py$$|\/pyproject.toml$$')" 96 96 97 + up-playwright: 98 + # Dump current DB once 99 + docker compose exec db sh -c 'if [ -f /tmp/care_db.before_playwright.dump ]; then echo "before_playwright dump already exists, skipping"; else pg_dump -U postgres -Fc care > /tmp/care_db.before_playwright.dump; fi' 100 + 101 + # If /tmp/test_db exists -> restore; else create blank DB, run migrations+fixtures, then dump 102 + @if docker compose exec db sh -c 'test -f /tmp/test_db'; then \ 103 + echo "Restoring /tmp/test_db"; \ 104 + docker compose exec db psql -U postgres -d postgres -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'care' AND pid <> pg_backend_pid();" || true; \ 105 + docker compose exec db pg_restore -U postgres --clean --if-exists -d care /tmp/test_db; \ 106 + else \ 107 + echo "No /tmp/test_db found, creating blank DB"; \ 108 + docker compose exec db psql -U postgres -d postgres -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'care' AND pid <> pg_backend_pid();" || true; \ 109 + docker compose exec db dropdb -U postgres care 2>/dev/null || true; \ 110 + docker compose exec db createdb -U postgres care; \ 111 + echo "Running migrations and fixtures on blank DB"; \ 112 + docker compose exec backend bash -c "python manage.py migrate && python manage.py load_fixtures"; \ 113 + echo "Dumping /tmp/test_db for faster subsequent runs"; \ 114 + docker compose exec db sh -c 'pg_dump -U postgres -Fc care > /tmp/test_db'; \ 115 + fi 116 + 117 + down-playwright: 118 + docker compose exec db sh -c 'if [ -f /tmp/care_db.before_playwright.dump ]; then pg_restore -U postgres --clean --if-exists -d care /tmp/care_db.before_playwright.dump && rm -f /tmp/care_db.before_playwright.dump; else echo "no before_playwright dump to restore"; fi' 119 + 97 120 %: 98 121 docker compose exec backend bash -c "python manage.py $*"