fix(tools): preserve empty content in ReadResult.to_dict()

This commit is contained in:
Farukest 2026-03-01 02:42:15 +03:00
parent 7b23dbfe68
commit 7f1f4c2248
No known key found for this signature in database
GPG key ID: 73E2756B3FFF5241
2 changed files with 10 additions and 2 deletions

View file

@ -67,10 +67,18 @@ class TestReadResult:
def test_to_dict_omits_defaults(self):
r = ReadResult()
d = r.to_dict()
assert "content" not in d # empty string omitted
assert "error" not in d # None omitted
assert "similar_files" not in d # empty list omitted
def test_to_dict_preserves_empty_content(self):
"""Empty file should still have content key in the dict."""
r = ReadResult(content="", total_lines=0, file_size=0)
d = r.to_dict()
assert "content" in d
assert d["content"] == ""
assert d["total_lines"] == 0
assert d["file_size"] == 0
def test_to_dict_includes_values(self):
r = ReadResult(content="hello", total_lines=10, file_size=50, truncated=True)
d = r.to_dict()