Skip to content

Commit bbe110c

Browse files
committed
100% test coverage
1 parent ea5f72d commit bbe110c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/no_commit_to_branch_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
from unittest.mock import patch
4+
35
import pytest
46

57
from pre_commit_hooks.no_commit_to_branch import _default_branch
@@ -81,6 +83,14 @@ def test_default_branch_names(temp_git_dir, branch_name):
8183
assert main(()) == 1
8284

8385

86+
def test_default_branch_falls_back_when_empty_branch(tmpdir):
87+
with patch(
88+
'pre_commit_hooks.no_commit_to_branch.cmd_output',
89+
return_value='origin/',
90+
):
91+
assert _default_branch() == frozenset({'master', 'main'})
92+
93+
8494
def test_default_branch_detects_from_origin(tmpdir):
8595
remote = tmpdir.join('remote')
8696
cmd_output('git', 'init', '--', str(remote))

0 commit comments

Comments
 (0)