summaryrefslogtreecommitdiffstats
path: root/tests/commands/hook_impl_test.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-07-14 13:16:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-07-14 13:16:19 +0000
commitdea1ff8e8ce88840434d53977ff62683240f5b8f (patch)
tree60da4e1c735a2d2d89907609c5bb1b1638c4c648 /tests/commands/hook_impl_test.py
parentAdding upstream version 2.19.0. (diff)
downloadpre-commit-dea1ff8e8ce88840434d53977ff62683240f5b8f.tar.xz
pre-commit-dea1ff8e8ce88840434d53977ff62683240f5b8f.zip
Adding upstream version 2.20.0.upstream/2.20.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/commands/hook_impl_test.py')
-rw-r--r--tests/commands/hook_impl_test.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/commands/hook_impl_test.py b/tests/commands/hook_impl_test.py
index 3e20874..aa321da 100644
--- a/tests/commands/hook_impl_test.py
+++ b/tests/commands/hook_impl_test.py
@@ -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