Add test for multiple patterns

This commit is contained in:
David Paz 2022-07-15 10:05:35 +02:00
parent e01e1717b1
commit ac248b5011
No known key found for this signature in database
GPG key ID: 6600CC47B1C1B063

View file

@ -20,6 +20,18 @@ def test_current_branch(temp_git_dir):
# Input, expected value, branch, template
TESTS = (
(
b'',
b'',
'test', # this should not trigger anything
'prepare_commit_msg_prepend.j2',
),
(
b'',
b'[1.0.0] ',
'release/1.0.0', # but this should
'prepare_commit_msg_prepend.j2',
),
(
b'',
b'[TT-01] ',
@ -64,7 +76,8 @@ def test_update_commit_file(
with temp_git_dir.as_cwd():
path = temp_git_dir.join('COMMIT_EDITMSG')
path.write_binary(input_s)
ticket = branch_name.split('/')[1]
parts = branch_name.split('/')
ticket = parts[1] if len(parts) > 1 else parts[0]
jinja = get_jinja_env()
update_commit_file(jinja, path, template, ticket)
@ -89,6 +102,7 @@ def test_main(
argv=[
'-t', template,
'-p', '(?<=feature/).*',
'-p', '(?<=release/).*',
str(path),
],
) == 0