From 7479af462bee37d1d3209c221f6ca9108780650e Mon Sep 17 00:00:00 2001 From: nesquena-hermes <[email protected]> Date: Thu, 21 May 2026 00:06:53 +0000 Subject: [PATCH] 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. --- tests/test_workspace_git.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_workspace_git.py b/tests/test_workspace_git.py index 7c8a667b..659a914a 100644 --- a/tests/test_workspace_git.py +++ b/tests/test_workspace_git.py @@ -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")