Stage-394 test fix: set destructive env in test_git_commit_route_rejects_active_stream

The test was calling _handle_git_commit() directly in-process, but the
HERMES_WEBUI_WORKSPACE_GIT_DESTRUCTIVE=1 env var was only being set on the
test_server subprocess (via conftest.py L539). In-process the destructive
gate (returns 403) fires before the active-stream gate (returns 409), so
the test never reached the assertion it was trying to verify.

monkeypatch.setenv() restores the test's intent: confirm that when
destructive mode IS enabled, an active stream still blocks mutations with
the more specific 409 code.
This commit is contained in:
nesquena-hermes committed 2026-05-21 00:06:53 +00:00
1 parent 0774235987
commit 7479af462b
1 file changed
+8
+8
View File
@@ -890,6 +890,14 @@ def test_git_active_stream_lock_detection(monkeypatch):
def test_git_commit_route_rejects_active_stream(monkeypatch, tmp_path):
from api import routes
from api.config import STREAMS, STREAMS_LOCK
from api.workspace_git import WORKSPACE_GIT_DESTRUCTIVE_ENV
# Enable destructive ops for this in-process test — conftest.py sets the env
# var on the test_server subprocess env block, but this test calls
# _handle_git_commit() directly in the pytest process, which inherits
# the default-OFF setting. Without this monkeypatch, the destructive-mode
# gate fires first (403) before the active-stream check (409) can run.
monkeypatch.setenv(WORKSPACE_GIT_DESTRUCTIVE_ENV, "1")
repo = _init_repo(tmp_path / "repo")
(repo / "tracked.txt").write_text("one\n", encoding="utf-8")