mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 04:14:59 +00:00
feat: use IgnorantTemporaryDirectory and create actual repo1 and repo2 subdirs in test_setup_git_home_invalid_choice
This commit is contained in:
parent
4d08f9c6c5
commit
715a9a9c71
1 changed files with 11 additions and 9 deletions
|
@ -664,16 +664,18 @@ class TestMain(TestCase):
|
|||
mock_io_instance.prompt_ask.assert_not_called()
|
||||
|
||||
@patch("aider.main.InputOutput")
|
||||
@patch("aider.main.Path")
|
||||
def test_setup_git_home_invalid_choice(self, mock_path, mock_io):
|
||||
def test_setup_git_home_invalid_choice(self, mock_io):
|
||||
mock_io_instance = mock_io.return_value
|
||||
mock_io_instance.prompt_ask.side_effect = ["3", "1"]
|
||||
mock_path.home.return_value.glob.return_value = [
|
||||
Path("/home/user/repo1/.git"),
|
||||
Path("/home/user/repo2/.git"),
|
||||
]
|
||||
|
||||
result = setup_git_home(mock_io_instance)
|
||||
with IgnorantTemporaryDirectory() as temp_home:
|
||||
with patch("aider.main.Path.home", return_value=Path(temp_home)):
|
||||
# Create actual repo1 and repo2 subdirectories with .git folders
|
||||
Path(temp_home, "repo1", ".git").mkdir(parents=True)
|
||||
Path(temp_home, "repo2", ".git").mkdir(parents=True)
|
||||
|
||||
self.assertEqual(result, Path("/home/user/repo1"))
|
||||
mock_io_instance.tool_error.assert_called_with("Please enter a number between 1 and 2")
|
||||
result = setup_git_home(mock_io_instance)
|
||||
|
||||
self.assertEqual(result, Path(temp_home) / "repo1")
|
||||
mock_io_instance.tool_error.assert_called_with("Please enter a number between 1 and 2")
|
||||
mock_io_instance.tool_output.assert_called_with("Found git repositories in your home directory:")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue