mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 08:14:59 +00:00
added test_update_files_live_diff
This commit is contained in:
parent
aacbcd32d4
commit
d7ba886e66
1 changed files with 19 additions and 0 deletions
|
@ -8,6 +8,7 @@ from unittest.mock import MagicMock, patch
|
|||
from aider import models
|
||||
from aider.coders import Coder
|
||||
from aider.coders.wholefile_coder import WholeFileCoder
|
||||
from aider.dump import dump # noqa: F401
|
||||
from aider.io import InputOutput
|
||||
|
||||
|
||||
|
@ -76,6 +77,24 @@ class TestWholeFileCoder(unittest.TestCase):
|
|||
updated_content = f.read()
|
||||
self.assertEqual(updated_content, "Updated content\n")
|
||||
|
||||
def test_update_files_live_diff(self):
|
||||
# Create a sample file in the temporary directory
|
||||
sample_file = "sample.txt"
|
||||
with open(sample_file, "w") as f:
|
||||
f.write("\n".join(map(str, range(0, 100))))
|
||||
|
||||
# Initialize WholeFileCoder with the temporary directory
|
||||
io = InputOutput(yes=True)
|
||||
coder = WholeFileCoder(main_model=models.GPT35, io=io, fnames=[sample_file])
|
||||
|
||||
# Set the partial response content with the updated content
|
||||
coder.partial_response_content = f"{sample_file}\n```\n0\n\1\n2\n"
|
||||
|
||||
lines = coder.update_files(mode="diff").splitlines()
|
||||
|
||||
# the live diff should be concise, since we haven't changed anything yet
|
||||
self.assertLess(len(lines), 20)
|
||||
|
||||
def test_update_files_with_existing_fence(self):
|
||||
# Create a sample file in the temporary directory
|
||||
sample_file = "sample.txt"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue