From da6f83b6672345400c133259a954c049ae0f437f Mon Sep 17 00:00:00 2001 From: argszero Date: Sat, 18 Jul 2026 14:11:33 +0800 Subject: [PATCH] emrg: add write_tool content-too-large error path test --- tests/test_write_tool.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_write_tool.py b/tests/test_write_tool.py index 4c6042bd..605bc037 100644 --- a/tests/test_write_tool.py +++ b/tests/test_write_tool.py @@ -89,3 +89,17 @@ def test_write_large_content_ok(temp_dir): assert not result.error assert "Created" in result.content assert len(filepath.read_text()) == 100_000 + + +def test_write_content_too_large(temp_dir, monkeypatch): + """Content exceeding MAX_WRITE_SIZE must return an error.""" + monkeypatch.setattr("emrg.tools.write_tool.MAX_WRITE_SIZE", 100) + tool = WriteTool() + filepath = temp_dir / "test.txt" + result = _run(tool.execute({ + "file_path": str(filepath), + "content": "x" * 200, + })) + assert result.error + assert "too large" in result.content + assert not filepath.exists()