mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 05:45:00 +00:00
brought over test_cmd_add_from_subdir from pr #97
This commit is contained in:
parent
450a5fff19
commit
0a5155e5bd
1 changed files with 38 additions and 0 deletions
|
@ -220,3 +220,41 @@ class TestCommands(TestCase):
|
|||
|
||||
self.assertIn("foo.txt", console_output)
|
||||
self.assertIn("bar.txt", console_output)
|
||||
|
||||
def test_cmd_add_from_subdir(self):
|
||||
repo = git.Repo.init()
|
||||
repo.config_writer().set_value("user", "name", "Test User").release()
|
||||
repo.config_writer().set_value("user", "email", "testuser@example.com").release()
|
||||
|
||||
# Create three empty files and add them to the git repository
|
||||
filenames = ["one.py", Path("subdir") / "two.py", Path("anotherdir") / "three.py"]
|
||||
for filename in filenames:
|
||||
file_path = Path(filename)
|
||||
file_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
file_path.touch()
|
||||
repo.git.add(str(file_path))
|
||||
repo.git.commit("-m", "added")
|
||||
|
||||
filenames = [str(Path(fn).resolve()) for fn in filenames]
|
||||
|
||||
###
|
||||
|
||||
os.chdir("subdir")
|
||||
|
||||
io = InputOutput(pretty=False, yes=True)
|
||||
coder = Coder.create(models.GPT35, None, io)
|
||||
commands = Commands(io, coder)
|
||||
|
||||
# this should get added
|
||||
commands.cmd_add(str(Path("anotherdir") / "three.py"))
|
||||
|
||||
# this should add one.py
|
||||
commands.cmd_add("*.py")
|
||||
|
||||
self.assertIn(filenames[0], coder.abs_fnames)
|
||||
self.assertNotIn(filenames[1], coder.abs_fnames)
|
||||
self.assertIn(filenames[2], coder.abs_fnames)
|
||||
|
||||
del commands
|
||||
del coder
|
||||
del io
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue