@@ -255,6 +255,38 @@ def test_pre_commit_exec_failed(
255
255
commands .Init (config )()
256
256
257
257
258
+ class TestAskTagFormat :
259
+ def test_confirm_v_tag_format (self , mocker : MockFixture , config ):
260
+ init = commands .Init (config )
261
+ mocker .patch ("questionary.confirm" , return_value = FakeQuestion (True ))
262
+
263
+ result = init ._ask_tag_format ("v1.0.0" )
264
+ assert result == r"v$version"
265
+
266
+ def test_reject_v_tag_format (self , mocker : MockFixture , config ):
267
+ init = commands .Init (config )
268
+ mocker .patch ("questionary.confirm" , return_value = FakeQuestion (False ))
269
+ mocker .patch ("questionary.text" , return_value = FakeQuestion ("custom-$version" ))
270
+
271
+ result = init ._ask_tag_format ("v1.0.0" )
272
+ assert result == "custom-$version"
273
+
274
+ def test_non_v_tag_format (self , mocker : MockFixture , config ):
275
+ init = commands .Init (config )
276
+ mocker .patch ("questionary.text" , return_value = FakeQuestion ("custom-$version" ))
277
+
278
+ result = init ._ask_tag_format ("1.0.0" )
279
+ assert result == "custom-$version"
280
+
281
+ def test_empty_input_returns_default (self , mocker : MockFixture , config ):
282
+ init = commands .Init (config )
283
+ mocker .patch ("questionary.confirm" , return_value = FakeQuestion (False ))
284
+ mocker .patch ("questionary.text" , return_value = FakeQuestion ("" ))
285
+
286
+ result = init ._ask_tag_format ("v1.0.0" )
287
+ assert result == "$version" # This is the default format from DEFAULT_SETTINGS
288
+
289
+
258
290
@skip_below_py_3_10
259
291
def test_init_command_shows_description_when_use_help_option (
260
292
mocker : MockFixture , capsys , file_regression
0 commit comments