Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests(git): add test to cover not a git repository case #311

Merged
merged 1 commit into from Jul 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion tests/git_test.py
Expand Up @@ -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'
Expand Down Expand Up @@ -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',
Expand Down