Enabling testing inside Docker container
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
DATABASE_URL=postgresql+psycopg2://postgres:postgres@localhost:5432/url_db
|
||||
BASE_URL=http://localhost:8000
|
||||
DEBUG=True
|
||||
+40
-3
@@ -1,7 +1,44 @@
|
||||
app/__pycache__
|
||||
__pycache__
|
||||
.pytest_cache/
|
||||
# Environment variables
|
||||
.env
|
||||
.env.local
|
||||
.env.*
|
||||
|
||||
# Keep the example file for setup instructions
|
||||
!.env.example
|
||||
|
||||
# Virtual environments
|
||||
venv/
|
||||
.env/
|
||||
|
||||
# Python bytecode and cache
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
.python-version
|
||||
|
||||
# Pytest cache
|
||||
.pytest_cache/
|
||||
|
||||
# IDE/editor files
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# Docker-related files
|
||||
*.log
|
||||
docker-compose.override.yml
|
||||
|
||||
# Coverage reports
|
||||
htmlcov/
|
||||
.coverage
|
||||
coverage.xml
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
|
||||
# Extras
|
||||
test.txt
|
||||
diff.txt
|
||||
test.db
|
||||
@@ -40,11 +40,6 @@ http://localhost:9995/docs
|
||||
Test Short URL Endpoint:<br>
|
||||
http://localhost:9995/shorten
|
||||
|
||||
## Run Tests
|
||||
```bash
|
||||
pytest --cov=app --cov-report=term-missing
|
||||
```
|
||||
|
||||
## Running Alembic revision
|
||||
```bash
|
||||
cd <your-repo-url>
|
||||
@@ -56,3 +51,10 @@ alembic revision --autogenerate -m "create urls table"
|
||||
cd <your-repo-url>
|
||||
docker compose up --build
|
||||
```
|
||||
|
||||
## Running tests in Docker container
|
||||
```bash
|
||||
cd <your-repo-url>
|
||||
docker compose up --build
|
||||
docker compose exec app pytest --cov=app --cov-report=term-missing
|
||||
```
|
||||
@@ -26,6 +26,8 @@ services:
|
||||
BASE_URL: http://localhost:9995
|
||||
ports:
|
||||
- "9995:9995"
|
||||
volumes:
|
||||
- .:/app # Mount current directory to /app inside container
|
||||
command: >
|
||||
sh -c "alembic upgrade head &&
|
||||
uvicorn app.main:app --host 0.0.0.0 --port 9995"
|
||||
|
||||
@@ -8,3 +8,4 @@ pydantic-settings==2.8.1
|
||||
pytest==8.3.5
|
||||
pytest-cov==5.0.0
|
||||
ruff==0.15.4
|
||||
httpx==0.24.1
|
||||
Reference in New Issue
Block a user