Skip to content

Commit aecd5f7

Browse files
committed
test(service): add test for handling unexpected errors during file editing to ensure robustness of error handling logic
1 parent 1034a84 commit aecd5f7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/test_service.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,24 @@ def test_edit_file_contents_file_error(service):
164164
edit_result = result[file_path]
165165
assert edit_result.result == "error"
166166
assert "no such file" in edit_result.reason.lower()
167+
168+
169+
def test_edit_file_unexpected_error(service, tmp_path):
170+
"""Test handling of unexpected errors during file editing."""
171+
# Setup test file and operation
172+
test_file = str(tmp_path / "error_test.txt")
173+
operation = EditFileOperation(
174+
path=test_file,
175+
hash="dummy_hash",
176+
patches=[EditPatch(contents="test content\n", line_start=1)],
177+
)
178+
179+
# Try to edit non-existent file
180+
result = service.edit_file_contents(test_file, operation)
181+
edit_result = result[test_file]
182+
183+
# Verify error handling
184+
assert edit_result.result == "error"
185+
assert "no such file" in edit_result.reason.lower()
186+
assert edit_result.hash is None
187+
assert edit_result.content is None

0 commit comments

Comments
 (0)