Skip to content

Commit 5a73d5c

Browse files
committed
test: state the pushed range in two files tests
Both tests passed made-up shas through the pre-push line and left get_push_commits unpatched, so git itself was asked about commits that do not exist. They now state the range, as the first test of the class does, and no longer start a git process.
1 parent 576fac4 commit 5a73d5c

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎tests/engine_test.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4301,6 +4301,14 @@ def test_tag_validator_pre_push_tag_deletion_skips(self):
43014301
assert result == ValidationResult.SKIP
43024302

43034303

4304+
def _pushed_tip_alone(local_sha, remote_sha):
4305+
"""A pushed range that holds the tip and nothing before it.
4306+
4307+
Stands in for git, so that the made-up shas of a test are never looked up.
4308+
"""
4309+
return [local_sha]
4310+
4311+
43044312
class TestFilesValidator:
43054313
@patch("commit_check.engine.get_push_commits")
43064314
@patch("commit_check.engine.get_commit_files")
@@ -4504,6 +4512,7 @@ def test_unknown_check_name_passes_defensively(self, mock_files):
45044512
validator = FilesValidator(rule)
45054513
assert validator.validate(ValidationContext()) == ValidationResult.PASS
45064514

4515+
@patch("commit_check.engine.get_push_commits", new=_pushed_tip_alone)
45074516
@patch("commit_check.engine.get_commit_files")
45084517
@pytest.mark.benchmark
45094518
def test_pre_push_stdin_validates_the_pushed_sha(self, mock_files):
@@ -4516,6 +4525,7 @@ def test_pre_push_stdin_validates_the_pushed_sha(self, mock_files):
45164525
assert result == ValidationResult.PASS
45174526
mock_files.assert_called_once_with("abc123")
45184527

4528+
@patch("commit_check.engine.get_push_commits", new=_pushed_tip_alone)
45194529
@patch("commit_check.engine.get_commit_files")
45204530
@pytest.mark.benchmark
45214531
def test_pre_push_stdin_validates_every_pushed_ref(self, mock_files):

0 commit comments

Comments
 (0)