test: add test for graceful exit when git command not found

This commit is contained in:
Paul Gauthier (aider) 2024-08-31 07:46:33 -07:00
parent 7ab1cf5160
commit 81981e7e99

View file

@ -619,3 +619,14 @@ class TestMain(TestCase):
return_coder=True,
)
self.assertTrue(coder.suggest_shell_commands)
@patch('git.Repo.init')
def test_main_exit_with_git_command_not_found(self, mock_git_init):
mock_git_init.side_effect = git.exc.GitCommandNotFound('git')
try:
result = main(["--exit"], input=DummyInput(), output=DummyOutput())
except Exception as e:
self.fail(f"main() raised an unexpected exception: {e}")
self.assertIsNone(result, "main() should return None when called with --exit")