Skip to content

Commit 9f3fb47

Browse files
authored
tests(git): add test to cover not a git repository case (#311)
This commit adds a test to cover the folder is not a git repository corner case.
1 parent ecc6a6e commit 9f3fb47

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

tests/git_test.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from unittest import mock
99

1010
import coveralls.git
11-
11+
from coveralls.exception import CoverallsException
1212

1313
GIT_COMMIT_MSG = 'first commit'
1414
GIT_EMAIL = '[email protected]'
@@ -108,6 +108,22 @@ def test_gitlog_envvars(self):
108108
}
109109

110110

111+
class GitInfoTestNotAGitRepository(unittest.TestCase):
112+
def setUp(self):
113+
self.dir = tempfile.mkdtemp()
114+
115+
os.chdir(self.dir)
116+
117+
def tearDown(self):
118+
shutil.rmtree(self.dir)
119+
120+
def test_gitlog_not_a_git_repo(self):
121+
git_info = coveralls.git.git_info()
122+
123+
self.assertRaises(CoverallsException)
124+
assert git_info == {}
125+
126+
111127
class GitInfoTestBranch(GitTest):
112128
@mock.patch.dict(os.environ, {
113129
'GITHUB_ACTIONS': 'true',

0 commit comments

Comments
 (0)