Handle files in the git repo which have been deleted but not committed, with test

This commit is contained in:
Paul Gauthier 2023-07-21 15:41:57 -03:00
parent 6d044485f3
commit dfd92073f4
2 changed files with 25 additions and 2 deletions

View file

@ -24,6 +24,29 @@ class TestCoder(unittest.TestCase):
def tearDown(self):
self.patcher.stop()
def test_get_last_modified(self):
# Mock the IO object
mock_io = MagicMock()
with GitTemporaryDirectory():
repo = git.Repo(Path.cwd())
fname = Path("new.txt")
fname.touch()
repo.git.add(str(fname))
repo.git.commit("-m", "new")
# Initialize the Coder object with the mocked IO and mocked repo
coder = Coder.create(models.GPT4, None, mock_io)
mod = coder.get_last_modified()
fname.write_text("hi")
mod_newer = coder.get_last_modified()
self.assertLess(mod, mod_newer)
fname.unlink()
self.assertEqual(coder.get_last_modified(), 0)
def test_should_dirty_commit(self):
# Mock the IO object
mock_io = MagicMock()