mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2026-01-17 11:40:39 +03:00
Add test database configuration and schema creation for testing
This commit is contained in:
@@ -33,6 +33,8 @@ class Settings(BaseSettings):
|
||||
POSTGRES_PASSWORD: str
|
||||
POSTGRES_HOST: str
|
||||
POSTGRES_DB: str
|
||||
POSTGRES_TEST_USER: str
|
||||
POSTGRES_TEST_DB: str
|
||||
|
||||
@computed_field
|
||||
@property
|
||||
@@ -80,6 +82,17 @@ class Settings(BaseSettings):
|
||||
path=self.POSTGRES_DB,
|
||||
)
|
||||
|
||||
@computed_field
|
||||
@property
|
||||
def test_asyncpg_url(self) -> PostgresDsn:
|
||||
return MultiHostUrl.build(
|
||||
scheme="postgresql+asyncpg",
|
||||
username=self.POSTGRES_USER,
|
||||
password=self.POSTGRES_PASSWORD,
|
||||
host=self.POSTGRES_HOST,
|
||||
path=self.POSTGRES_TEST_DB,
|
||||
)
|
||||
|
||||
@computed_field
|
||||
@property
|
||||
def postgres_url(self) -> PostgresDsn:
|
||||
|
||||
Reference in New Issue
Block a user