Skip to content

Commit

Permalink
chore: add and fix post-checkout hook tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalii Budnik committed Dec 23, 2024
1 parent 91bab6c commit 8d3c93c
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions tests/commands/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ def test_commit_msg_hook(cap_out, store, commit_msg_repo):
)


def test_post_checkout_hook(cap_out, store, tempdir_factory):
def test_post_checkout_hook_run(cap_out, store, tempdir_factory):
path = git_dir(tempdir_factory)
config = {
'repo': 'meta', 'hooks': [
Expand All @@ -878,12 +878,31 @@ def test_post_checkout_hook(cap_out, store, tempdir_factory):
cap_out,
store,
path,
{'hook_stage': 'post-checkout'},
{'hook_stage': 'post-checkout', 'from_ref': 'a', 'to_ref': 'b', 'checkout_type': '1'},
expected_outputs=[b'identity...'],
expected_ret=0,
stage=False,
)

def test_post_checkout_hook_skip(cap_out, store, tempdir_factory):
path = git_dir(tempdir_factory)
config = {
'repo': 'meta', 'hooks': [
{'id': 'identity', 'stages': ['post-checkout']},
],
}
add_config_to_repo(path, config)

with cwd(path):
_test_run(
cap_out,
store,
path,
{'hook_stage': 'post-checkout', 'from_ref': 'a', 'to_ref': 'a'},
expected_outputs=[b"Skipping `post-checkout` hooks since it's a file checkout or same head ref"],
expected_ret=0,
stage=False,
)

def test_prepare_commit_msg_hook(cap_out, store, prepare_commit_msg_repo):
filename = '.git/COMMIT_EDITMSG'
Expand Down

0 comments on commit 8d3c93c

Please sign in to comment.