summaryrefslogtreecommitdiffstats
path: root/tests/test_project.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_project.py')
-rw-r--r--tests/test_project.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/tests/test_project.py b/tests/test_project.py
index d578fe84..4f449227 100644
--- a/tests/test_project.py
+++ b/tests/test_project.py
@@ -347,6 +347,10 @@ class MigrateWorkTreeTests(unittest.TestCase):
347 } 347 }
348 _FILES = { 348 _FILES = {
349 'COMMIT_EDITMSG', 'FETCH_HEAD', 'HEAD', 'index', 'ORIG_HEAD', 349 'COMMIT_EDITMSG', 'FETCH_HEAD', 'HEAD', 'index', 'ORIG_HEAD',
350 'unknown-file-should-be-migrated',
351 }
352 _CLEAN_FILES = {
353 'a-vim-temp-file~', '#an-emacs-temp-file#',
350 } 354 }
351 355
352 @classmethod 356 @classmethod
@@ -365,10 +369,9 @@ class MigrateWorkTreeTests(unittest.TestCase):
365 dotgit.mkdir(parents=True) 369 dotgit.mkdir(parents=True)
366 for name in cls._SYMLINKS: 370 for name in cls._SYMLINKS:
367 (dotgit / name).symlink_to(f'../../../.repo/projects/src/test.git/{name}') 371 (dotgit / name).symlink_to(f'../../../.repo/projects/src/test.git/{name}')
368 for name in cls._FILES: 372 for name in cls._FILES | cls._CLEAN_FILES:
369 (dotgit / name).write_text(name) 373 (dotgit / name).write_text(name)
370 374
371 subprocess.run(['tree', '-a', str(dotgit)])
372 yield tempdir 375 yield tempdir
373 376
374 def test_standard(self): 377 def test_standard(self):
@@ -385,3 +388,24 @@ class MigrateWorkTreeTests(unittest.TestCase):
385 gitdir = tempdir / '.repo/projects/src/test.git' 388 gitdir = tempdir / '.repo/projects/src/test.git'
386 for name in self._FILES: 389 for name in self._FILES:
387 self.assertEqual(name, (gitdir / name).read_text()) 390 self.assertEqual(name, (gitdir / name).read_text())
391 # Make sure files were removed.
392 for name in self._CLEAN_FILES:
393 self.assertFalse((gitdir / name).exists())
394
395 def test_unknown(self):
396 """A checkout with unknown files should abort."""
397 with self._simple_layout() as tempdir:
398 dotgit = tempdir / 'src/test/.git'
399 (tempdir / '.repo/projects/src/test.git/random-file').write_text('one')
400 (dotgit / 'random-file').write_text('two')
401 with self.assertRaises(error.GitError):
402 project.Project._MigrateOldWorkTreeGitDir(str(dotgit))
403
404 # Make sure no content was actually changed.
405 self.assertTrue(dotgit.is_dir())
406 for name in self._FILES:
407 self.assertTrue((dotgit / name).is_file())
408 for name in self._CLEAN_FILES:
409 self.assertTrue((dotgit / name).is_file())
410 for name in self._SYMLINKS:
411 self.assertTrue((dotgit / name).is_symlink())