V6.1 runtime settings ->.env.production fix
Quality Gate / gate (push) Successful in 2m29s

This commit is contained in:
Jim Lancaster
2026-09-02 12:31:04 -05:00
parent 16391463d6
commit 15a4814e23
2 changed files with 32 additions and 1 deletions
+16
View File
@@ -2,6 +2,7 @@
from __future__ import annotations
import errno
from pathlib import Path
import pytest
@@ -132,3 +133,18 @@ def test_save_runtime_settings_surfaces_unwritable_target(tmp_path: Path, monkey
with pytest.raises(AppError) as exc:
save_runtime_settings(settings=settings, updates={"port": "9001"}, env_file_path=env_path)
assert exc.value.message == "Runtime settings file is not writable."
def test_save_runtime_settings_falls_back_when_atomic_replace_is_unavailable(tmp_path: Path, monkeypatch):
settings = _settings_for_runtime_editing(tmp_path)
env_path = tmp_path / ".env.production"
env_path.write_text("OPENROUTER_API_KEY=test-key\nPORT=8000\n", encoding="utf-8")
def _replace_cross_device(_self: Path, _target: Path) -> Path:
raise OSError(errno.EXDEV, "Invalid cross-device link")
monkeypatch.setattr(Path, "replace", _replace_cross_device)
snapshot = save_runtime_settings(settings=settings, updates={"port": "9001"}, env_file_path=env_path)
assert snapshot.env_file_path == env_path
assert "PORT=9001" in env_path.read_text(encoding="utf-8")