Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c130d5e

Browse files
committed
test(cz/customize): add test example for jinja support
#54
1 parent 948150d commit c130d5e

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

tests/test_cz_customize.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
@pytest.fixture(scope="module")
99
def config():
1010
_conf = Config()
11-
toml_str = """
11+
toml_str = r"""
1212
[tool.commitizen.customize]
1313
# message_template should follow the python string formatting spec
14-
message_template = "{{change_type}}: {{message}}"
14+
message_template = "{{change_type}}:{% if show_message %} {{message}}{% endif %}"
1515
example = "feature: this feature eanable customize through config file"
1616
schema = "<type>: <body>"
1717
bump_pattern = "^(break|new|fix|hotfix)"
@@ -31,6 +31,11 @@ def config():
3131
type = "input"
3232
name = "message"
3333
message = "Body."
34+
35+
[[tool.commitizen.customize.questions]]
36+
type = "confirm"
37+
name = "show_message"
38+
message = "Do you want to add body message in commit?"
3439
"""
3540
_conf.update(parse(toml_str)["tool"]["commitizen"])
3641
return _conf.config
@@ -65,6 +70,11 @@ def test_questions(config):
6570
"message": "Select the type of change you are committing",
6671
},
6772
{"type": "input", "name": "message", "message": "Body."},
73+
{
74+
"type": "confirm",
75+
"name": "show_message",
76+
"message": "Do you want to add body message in commit?",
77+
},
6878
]
6979
assert list(questions) == expected_questions
7080

@@ -74,10 +84,20 @@ def test_answer(config):
7484
answers = {
7585
"change_type": "feature",
7686
"message": "this feature eanable customize through config file",
87+
"show_message": True,
7788
}
7889
message = cz.message(answers)
7990
assert message == "feature: this feature eanable customize through config file"
8091

92+
cz = CustomizeCommitsCz(config)
93+
answers = {
94+
"change_type": "feature",
95+
"message": "this feature eanable customize through config file",
96+
"show_message": False,
97+
}
98+
message = cz.message(answers)
99+
assert message == "feature:"
100+
81101

82102
def test_example(config):
83103
cz = CustomizeCommitsCz(config)

0 commit comments

Comments
 (0)