-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new test db for unit testing and some refactoring
- Loading branch information
1 parent
bd8f26d
commit 38a91e4
Showing
8 changed files
with
159 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,21 +115,29 @@ class SecretsManagerType(str, Enum): | |
|
||
|
||
ENV_ADMYRAL_DATABASE_URL = "ADMYRAL_DATABASE_URL" | ||
ENV_ADMYRAL_TEST_DATABASE_URL = "ADMYRAL_TEST_DATABASE_URL" | ||
ENV_ADMYRAL_SECRETS_MANAGER_TYPE = "ADMYRAL_SECRETS_MANAGER" | ||
|
||
|
||
ADMYRAL_DATABASE_URL = os.getenv( | ||
ENV_ADMYRAL_DATABASE_URL, | ||
"postgresql://postgres:your-super-secret-and-long-postgres-password@localhost:5432/admyral", | ||
) | ||
if ADMYRAL_DATABASE_URL.startswith("postgresql"): | ||
if ADMYRAL_DATABASE_URL.startswith("postgresql://"): | ||
ADMYRAL_DATABASE_URL = ADMYRAL_DATABASE_URL.replace( | ||
"postgresql://", "postgresql+asyncpg://" | ||
) | ||
ADMYRAL_DATABASE_TYPE = DatabaseType.POSTGRES | ||
else: | ||
raise NotImplementedError(f"Unsupported database type: {ADMYRAL_DATABASE_URL}") | ||
|
||
ADMYRAL_TEST_DATABASE_URL = os.getenv( | ||
ENV_ADMYRAL_TEST_DATABASE_URL, | ||
"postgresql://postgres:your-super-secret-and-long-postgres-password@localhost:5433/admyral", | ||
) | ||
|
||
if ADMYRAL_TEST_DATABASE_URL.startswith("postgresql://"): | ||
ADMYRAL_TEST_DATABASE_URL = ADMYRAL_TEST_DATABASE_URL.replace( | ||
"postgresql://", "postgresql+asyncpg://" | ||
) | ||
|
||
if ADMYRAL_DATABASE_URL.startswith("postgresql://"): | ||
ADMYRAL_DATABASE_URL = ADMYRAL_DATABASE_URL.replace( | ||
"postgresql://", "postgresql+asyncpg://" | ||
) | ||
|
||
ADMYRAL_SECRETS_MANAGER_TYPE = SecretsManagerType( | ||
os.getenv(ENV_ADMYRAL_SECRETS_MANAGER_TYPE, SecretsManagerType.SQL) | ||
|
@@ -151,8 +159,8 @@ class GlobalConfig(BaseModel): | |
default_user_email: str = "[email protected]" | ||
telemetry_disabled: bool = ADMYRAL_DISABLE_TELEMETRY | ||
storage_directory: str = get_local_storage_path() | ||
database_type: DatabaseType = ADMYRAL_DATABASE_TYPE | ||
database_url: str = ADMYRAL_DATABASE_URL | ||
test_database_url: str = ADMYRAL_TEST_DATABASE_URL | ||
temporal_host: str = ADMYRAL_TEMPORAL_HOST | ||
secrets_manager_type: SecretsManagerType = ADMYRAL_SECRETS_MANAGER_TYPE | ||
posthog_api_key: str = ADMYRAL_POSTHOG_API_KEY | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.