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__
|
# Environment variables
|
||||||
__pycache__
|
.env
|
||||||
.pytest_cache/
|
.env.local
|
||||||
|
.env.*
|
||||||
|
|
||||||
|
# Keep the example file for setup instructions
|
||||||
|
!.env.example
|
||||||
|
|
||||||
|
# Virtual environments
|
||||||
venv/
|
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
|
test.txt
|
||||||
diff.txt
|
diff.txt
|
||||||
test.db
|
test.db
|
||||||
@@ -40,11 +40,6 @@ http://localhost:9995/docs
|
|||||||
Test Short URL Endpoint:<br>
|
Test Short URL Endpoint:<br>
|
||||||
http://localhost:9995/shorten
|
http://localhost:9995/shorten
|
||||||
|
|
||||||
## Run Tests
|
|
||||||
```bash
|
|
||||||
pytest --cov=app --cov-report=term-missing
|
|
||||||
```
|
|
||||||
|
|
||||||
## Running Alembic revision
|
## Running Alembic revision
|
||||||
```bash
|
```bash
|
||||||
cd <your-repo-url>
|
cd <your-repo-url>
|
||||||
@@ -55,4 +50,11 @@ alembic revision --autogenerate -m "create urls table"
|
|||||||
```bash
|
```bash
|
||||||
cd <your-repo-url>
|
cd <your-repo-url>
|
||||||
docker compose up --build
|
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
|
BASE_URL: http://localhost:9995
|
||||||
ports:
|
ports:
|
||||||
- "9995:9995"
|
- "9995:9995"
|
||||||
|
volumes:
|
||||||
|
- .:/app # Mount current directory to /app inside container
|
||||||
command: >
|
command: >
|
||||||
sh -c "alembic upgrade head &&
|
sh -c "alembic upgrade head &&
|
||||||
uvicorn app.main:app --host 0.0.0.0 --port 9995"
|
uvicorn app.main:app --host 0.0.0.0 --port 9995"
|
||||||
|
|||||||
+2
-1
@@ -7,4 +7,5 @@ pydantic-settings==2.8.1
|
|||||||
|
|
||||||
pytest==8.3.5
|
pytest==8.3.5
|
||||||
pytest-cov==5.0.0
|
pytest-cov==5.0.0
|
||||||
ruff==0.15.4
|
ruff==0.15.4
|
||||||
|
httpx==0.24.1
|
||||||
Reference in New Issue
Block a user