Skip to content

Commit

Permalink
🔧 build: Update database configuration for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
AndPuQing committed Feb 25, 2024
1 parent 93387b9 commit 0ca300b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
13 changes: 9 additions & 4 deletions backend/app/app/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@
from app.web.application import get_app


@pytest.fixture(name="session")
def session_fixture():
@pytest.fixture(scope="session")
def engine_fixture():
engine = create_engine(
f"postgresql+psycopg://{settings.POSTGRES_USER}:{settings.POSTGRES_PASSWORD}@bemore-db/{settings.POSTGRES_DB}",
f"postgresql+psycopg://{settings.POSTGRES_USER}:{settings.POSTGRES_PASSWORD}@bemore-db/test",
)
SQLModel.metadata.create_all(engine)

with Session(engine) as session:
init_db(session)
yield engine


@pytest.fixture(name="session")
def session_fixture(engine_fixture):
with Session(engine_fixture) as session:
yield session


Expand Down
2 changes: 1 addition & 1 deletion backend/app/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def convert_without_saving(
update: Optional[dict] = None,
) -> SQLModel:
if isinstance(source, SQLModel):
obj = cls.from_orm(source, update=update) # type: ignore
obj = cls.model_validate(source, update=update) # type: ignore
elif isinstance(source, dict):
obj = cls.parse_obj(source, update=update) # type: ignore
return obj
Expand Down
1 change: 1 addition & 0 deletions docker-compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
- .env
environment:
- PGDATA=/var/lib/postgresql/data/pgdata
- POSTGRES_DB=test
networks:
- default

Expand Down

0 comments on commit 0ca300b

Please sign in to comment.