From f86ffa10ee232c5c8c8cb53e77c41ee6ce36829e Mon Sep 17 00:00:00 2001 From: Venu Vardhan Reddy Tekula Date: Tue, 20 Jul 2021 01:24:46 +0530 Subject: [PATCH] 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. --- tests/git_test.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/git_test.py b/tests/git_test.py index ee629af..585ec5a 100644 --- a/tests/git_test.py +++ b/tests/git_test.py @@ -8,7 +8,7 @@ from unittest import mock import coveralls.git - +from coveralls.exception import CoverallsException GIT_COMMIT_MSG = 'first commit' GIT_EMAIL = 'me@here.com' @@ -108,6 +108,22 @@ def test_gitlog_envvars(self): } +class GitInfoTestNotAGitRepository(unittest.TestCase): + def setUp(self): + self.dir = tempfile.mkdtemp() + + os.chdir(self.dir) + + def tearDown(self): + shutil.rmtree(self.dir) + + def test_gitlog_not_a_git_repo(self): + git_info = coveralls.git.git_info() + + self.assertRaises(CoverallsException) + assert git_info == {} + + class GitInfoTestBranch(GitTest): @mock.patch.dict(os.environ, { 'GITHUB_ACTIONS': 'true',