CI: set db host for tests
This commit is contained in:
parent
4a54a815a0
commit
8bfb410ee1
4 changed files with 7 additions and 6 deletions
|
@ -33,7 +33,7 @@ jobs:
|
|||
run: uv pip install --python=$UV_PROJECT_ENVIRONMENT --no-deps .
|
||||
|
||||
- name: Run tests (API call)
|
||||
run: pytest -s tests/basic.py
|
||||
run: TREETRAIL_DB_HOST=treetrail-database pytest -s tests/basic.py
|
||||
|
||||
build:
|
||||
runs-on: container
|
||||
|
|
|
@ -31,4 +31,4 @@ jobs:
|
|||
run: uv pip install --python=$UV_PROJECT_ENVIRONMENT --no-deps .
|
||||
|
||||
- name: Run tests (API call)
|
||||
run: pytest -s tests/basic.py
|
||||
run: TREETRAIL_DB_HOST=treetrail-database pytest -s tests/basic.py
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Build: podman build -t code.philo.ydns.eu/philorg/treetrail-backend-base -f Containerfile.base
|
||||
# Build: podman build -t code.philo.ydns.eu/philorg/treetrail-backend -f Containerfile
|
||||
|
||||
FROM code.philo.ydns.eu/philorg/treetrail-backend-deps
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ from treetrail.config import conf
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
CREATE_DB_TIMEOUT = 30
|
||||
CREATE_DB_TIMEOUT = 10
|
||||
|
||||
engine = create_async_engine(
|
||||
conf.db.get_sqla_url(),
|
||||
|
@ -33,7 +33,7 @@ async def create_db(drop=False):
|
|||
await conn.run_sync(SQLModel.metadata.drop_all)
|
||||
await conn.run_sync(SQLModel.metadata.create_all)
|
||||
|
||||
logger.debug(f'Connect to database with config: {conf.db}')
|
||||
logger.debug(f"Connect to database with config: {conf.db}")
|
||||
while attempts > 0:
|
||||
try:
|
||||
await try_once()
|
||||
|
@ -68,6 +68,7 @@ async def populate_init_db():
|
|||
"""Populate the database for a fresh install"""
|
||||
from sqlalchemy import text
|
||||
from treetrail.security import create_user, add_role, add_user_role
|
||||
|
||||
logger.info("Populating initial database")
|
||||
|
||||
user = await create_user(username="admin", password="admin")
|
||||
|
@ -76,7 +77,7 @@ async def populate_init_db():
|
|||
async with db_session() as session:
|
||||
for initial in initials:
|
||||
await session.execute(text(initial))
|
||||
logger.debug(f'Added map style {initial}')
|
||||
logger.debug(f"Added map style {initial}")
|
||||
await session.commit()
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue