100% test coverage

This commit is contained in:
emanb29 2026-04-04 14:08:18 -07:00
parent ea5f72dd61
commit bbe110c1c1
No known key found for this signature in database

View file

@ -1,5 +1,7 @@
from __future__ import annotations from __future__ import annotations
from unittest.mock import patch
import pytest import pytest
from pre_commit_hooks.no_commit_to_branch import _default_branch 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 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): def test_default_branch_detects_from_origin(tmpdir):
remote = tmpdir.join('remote') remote = tmpdir.join('remote')
cmd_output('git', 'init', '--', str(remote)) cmd_output('git', 'init', '--', str(remote))