mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 11:36:54 +00:00
100% test coverage
This commit is contained in:
parent
ea5f72dd61
commit
bbe110c1c1
1 changed files with 10 additions and 0 deletions
|
|
@ -1,5 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
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):
|
|||
assert main(()) == 1
|
||||
|
||||
|
||||
def test_default_branch_falls_back_when_empty_branch(tmpdir):
|
||||
with patch(
|
||||
'pre_commit_hooks.no_commit_to_branch.cmd_output',
|
||||
return_value='origin/',
|
||||
):
|
||||
assert _default_branch() == frozenset({'master', 'main'})
|
||||
|
||||
|
||||
def test_default_branch_detects_from_origin(tmpdir):
|
||||
remote = tmpdir.join('remote')
|
||||
cmd_output('git', 'init', '--', str(remote))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue