Skip to content

Commit 13c9303

Browse files
committed
test: add unittest for _construct_name_choice_with_description(
1 parent aa68f32 commit 13c9303

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/commands/test_init_command.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from commitizen import cmd, commands
1212
from commitizen.__version__ import __version__
13+
from commitizen.cz import registry
1314
from commitizen.exceptions import InitFailedError, NoAnswersError
1415

1516
if TYPE_CHECKING:
@@ -462,3 +463,22 @@ def test_init_configuration_with_version_provider(
462463
assert (
463464
"version = " not in config_data
464465
) # Version should not be set when using version_provider
466+
467+
468+
def test_construct_name_choice_with_description(
469+
config: BaseConfig, mocker: MockFixture
470+
):
471+
"""Test the construction of cz name choices with descriptions."""
472+
init = commands.Init(config)
473+
# mock the registry to have only one cz for testing
474+
mocker.patch.dict(
475+
"commitizen.cz.registry",
476+
{"cz_conventional_commits": registry["cz_conventional_commits"]},
477+
clear=True,
478+
)
479+
choices = init._construct_name_choice_with_description()
480+
assert len(choices) == 1
481+
choice = choices[0]
482+
assert choice.title == "cz_conventional_commits"
483+
assert choice.value == "cz_conventional_commits"
484+
assert choice.description == "<type>(<scope>): <subject>"

0 commit comments

Comments
 (0)