Compare commits
1 Commits
plan/issue
...
fix/issue-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e657f2bfbc |
@@ -11,6 +11,28 @@ from vigilar.config import VigilarConfig, load_config
|
|||||||
from vigilar.storage.schema import metadata
|
from vigilar.storage.schema import metadata
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True, scope="session")
|
||||||
|
def _isolate_vigilar_config(tmp_path_factory):
|
||||||
|
"""Prevent tests from writing to the real config/vigilar.toml.
|
||||||
|
|
||||||
|
Web endpoint handlers that call `_save_and_reload()` read the target
|
||||||
|
path from the VIGILAR_CONFIG env var, falling back to the relative
|
||||||
|
`"config/vigilar.toml"`. Without this fixture, any test that exercises
|
||||||
|
such an endpoint rewrites the repo's committed config file via a
|
||||||
|
Pydantic round-trip, stripping comments and non-default fields.
|
||||||
|
"""
|
||||||
|
tmp_config = tmp_path_factory.mktemp("vigilar-config") / "vigilar.toml"
|
||||||
|
prev = os.environ.get("VIGILAR_CONFIG")
|
||||||
|
os.environ["VIGILAR_CONFIG"] = str(tmp_config)
|
||||||
|
try:
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
if prev is None:
|
||||||
|
os.environ.pop("VIGILAR_CONFIG", None)
|
||||||
|
else:
|
||||||
|
os.environ["VIGILAR_CONFIG"] = prev
|
||||||
|
|
||||||
|
|
||||||
def _create_test_engine(db_path: Path):
|
def _create_test_engine(db_path: Path):
|
||||||
"""Create a fresh engine for testing (bypasses the global singleton)."""
|
"""Create a fresh engine for testing (bypasses the global singleton)."""
|
||||||
db_path.parent.mkdir(parents=True, exist_ok=True)
|
db_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user