Skip to content

Commit

Permalink
Add prepare-commit-msg additional argument tests
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Whitaker committed May 29, 2022
1 parent e3f2c88 commit 1491bcb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
36 changes: 36 additions & 0 deletions tests/commands/hook_impl_test.py
Expand Up @@ -154,6 +154,42 @@ def test_run_ns_commit_msg():
assert ns.commit_msg_filename == '.git/COMMIT_MSG'


def test_run_ns_prepare_commit_msg_one_arg():
ns = hook_impl._run_ns(
'prepare-commit-msg', False,
('.git/COMMIT_MSG',), b'',
)
assert ns is not None
assert ns.hook_stage == 'prepare-commit-msg'
assert ns.color is False
assert ns.commit_msg_filename == '.git/COMMIT_MSG'


def test_run_ns_prepare_commit_msg_two_arg():
ns = hook_impl._run_ns(
'prepare-commit-msg', False,
('.git/COMMIT_MSG', 'message'), b'',
)
assert ns is not None
assert ns.hook_stage == 'prepare-commit-msg'
assert ns.color is False
assert ns.commit_msg_filename == '.git/COMMIT_MSG'
assert ns.prepare_commit_message_source == 'message'


def test_run_ns_prepare_commit_msg_three_arg():
ns = hook_impl._run_ns(
'prepare-commit-msg', False,
('.git/COMMIT_MSG', 'message', 'HEAD'), b'',
)
assert ns is not None
assert ns.hook_stage == 'prepare-commit-msg'
assert ns.color is False
assert ns.commit_msg_filename == '.git/COMMIT_MSG'
assert ns.prepare_commit_message_source == 'message'
assert ns.commit_object_name == 'HEAD'


def test_run_ns_post_commit():
ns = hook_impl._run_ns('post-commit', True, (), b'')
assert ns is not None
Expand Down
7 changes: 6 additions & 1 deletion tests/commands/run_test.py
Expand Up @@ -810,7 +810,12 @@ def test_prepare_commit_msg_hook(cap_out, store, prepare_commit_msg_repo):
cap_out,
store,
prepare_commit_msg_repo,
{'hook_stage': 'prepare-commit-msg', 'commit_msg_filename': filename},
{
'hook_stage': 'prepare-commit-msg',
'commit_msg_filename': filename,
'prepare_commit_message_source': 'commit',
'commit_object_name': 'HEAD',
},
expected_outputs=[b'Add "Signed off by:"', b'Passed'],
expected_ret=0,
stage=False,
Expand Down

0 comments on commit 1491bcb

Please sign in to comment.