Added a test for failing get_root_dir inside the git folder

This commit is contained in:
Daniel Schürmann 2021-08-06 23:23:44 +02:00
parent c43698e942
commit 0d9f2d1466

View file

@ -19,6 +19,13 @@ def test_get_root_deeper(in_git_dir):
assert os.path.normcase(git.get_root()) == expected assert os.path.normcase(git.get_root()) == expected
def test_get_root_in_git_sub_dir(in_git_dir):
expected = os.path.normcase(in_git_dir.strpath)
with pytest.raises(FatalError):
with in_git_dir.join('.git/objects').ensure_dir().as_cwd():
assert os.path.normcase(git.get_root()) == expected
def test_in_exactly_dot_git(in_git_dir): def test_in_exactly_dot_git(in_git_dir):
with in_git_dir.join('.git').as_cwd(), pytest.raises(FatalError): with in_git_dir.join('.git').as_cwd(), pytest.raises(FatalError):
git.get_root() git.get_root()