refactor: standardize test database configuration across test files

This commit is contained in:
Anish Sarkar 2026-02-27 00:45:51 +05:30
parent f09b5b0ea4
commit 1068ea25a7
2 changed files with 8 additions and 9 deletions

View file

@ -4,10 +4,14 @@ from __future__ import annotations
import os
os.environ.setdefault(
"DATABASE_URL",
"postgresql+asyncpg://postgres:postgres@localhost:5432/surfsense_test",
_DEFAULT_TEST_DB = (
"postgresql+asyncpg://postgres:postgres@localhost:5432/surfsense_test"
)
TEST_DATABASE_URL = os.environ.get("TEST_DATABASE_URL", _DEFAULT_TEST_DB)
# Force the app to use the test database regardless of any pre-existing
# DATABASE_URL in the environment (e.g. from .env or shell profile).
os.environ["DATABASE_URL"] = TEST_DATABASE_URL
import pytest