kin: auto-commit after pipeline
This commit is contained in:
parent
f805aff86b
commit
6c2da26b6c
6 changed files with 138 additions and 10 deletions
|
|
@ -176,6 +176,43 @@ class TestRunProjectTests:
|
|||
assert result["success"] is False
|
||||
assert result["returncode"] == 124
|
||||
|
||||
def test_custom_test_command_used(self):
|
||||
"""KIN-ARCH-008: _run_project_tests вызывает subprocess с переданной командой."""
|
||||
from agents.runner import _run_project_tests
|
||||
mock_result = MagicMock()
|
||||
mock_result.returncode = 0
|
||||
mock_result.stdout = "2 passed"
|
||||
mock_result.stderr = ""
|
||||
with patch("agents.runner.subprocess.run", return_value=mock_result) as mock_sp, \
|
||||
patch("agents.runner.shutil.which", return_value=None):
|
||||
_run_project_tests("/fake/path", test_command="pytest -v")
|
||||
called_cmd = mock_sp.call_args[0][0]
|
||||
assert called_cmd[0] == "pytest"
|
||||
assert "-v" in called_cmd
|
||||
|
||||
def test_default_test_command_is_make_test(self):
|
||||
"""KIN-ARCH-008: без test_command параметра вызывается 'make test'."""
|
||||
from agents.runner import _run_project_tests
|
||||
mock_result = MagicMock()
|
||||
mock_result.returncode = 0
|
||||
mock_result.stdout = "OK"
|
||||
mock_result.stderr = ""
|
||||
with patch("agents.runner.subprocess.run", return_value=mock_result) as mock_sp, \
|
||||
patch("agents.runner.shutil.which", return_value=None):
|
||||
_run_project_tests("/fake/path")
|
||||
called_cmd = mock_sp.call_args[0][0]
|
||||
assert called_cmd[0] == "make"
|
||||
assert "test" in called_cmd
|
||||
|
||||
def test_custom_command_not_found_returns_127(self):
|
||||
"""KIN-ARCH-008: кастомная команда не найдена → returncode 127."""
|
||||
from agents.runner import _run_project_tests
|
||||
with patch("agents.runner.subprocess.run", side_effect=FileNotFoundError), \
|
||||
patch("agents.runner.shutil.which", return_value=None):
|
||||
result = _run_project_tests("/fake/path", test_command="nonexistent-cmd --flag")
|
||||
assert result["success"] is False
|
||||
assert result["returncode"] == 127
|
||||
|
||||
|
||||
def _mock_success(output="done"):
|
||||
m = MagicMock()
|
||||
|
|
@ -302,6 +339,26 @@ class TestAutoTestInPipeline:
|
|||
|
||||
mock_tests.assert_not_called()
|
||||
|
||||
@patch("agents.runner._run_autocommit")
|
||||
@patch("agents.runner._run_project_tests")
|
||||
@patch("agents.runner.subprocess.run")
|
||||
def test_auto_test_uses_project_test_command(
|
||||
self, mock_run, mock_tests, mock_autocommit, conn
|
||||
):
|
||||
"""KIN-ARCH-008: pipeline передаёт project.test_command в _run_project_tests."""
|
||||
from agents.runner import run_pipeline
|
||||
from core import models
|
||||
mock_run.return_value = _mock_success()
|
||||
mock_tests.return_value = {"success": True, "output": "OK", "returncode": 0}
|
||||
models.update_project(conn, "vdol", auto_test_enabled=True, test_command="npm test")
|
||||
|
||||
steps = [{"role": "backend_dev", "brief": "implement"}]
|
||||
run_pipeline(conn, "VDOL-001", steps)
|
||||
|
||||
mock_tests.assert_called_once()
|
||||
called_test_command = mock_tests.call_args[0][1]
|
||||
assert called_test_command == "npm test"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# (3) Spec-driven workflow route
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue