@@ -324,6 +324,54 @@ def test_commit_when_nothing_to_commit(config, mocker: MockFixture):
324
324
assert "No files added to staging!" in str (excinfo .value )
325
325
326
326
327
+ @pytest .mark .usefixtures ("staging_is_clean" )
328
+ def test_commit_with_allow_empty (config , mocker : MockFixture ):
329
+ prompt_mock = mocker .patch ("questionary.prompt" )
330
+ prompt_mock .return_value = {
331
+ "prefix" : "feat" ,
332
+ "subject" : "user created" ,
333
+ "scope" : "" ,
334
+ "is_breaking_change" : False ,
335
+ "body" : "closes #21" ,
336
+ "footer" : "" ,
337
+ }
338
+
339
+ commit_mock = mocker .patch ("commitizen.git.commit" )
340
+ commit_mock .return_value = cmd .Command ("success" , "" , b"" , b"" , 0 )
341
+ success_mock = mocker .patch ("commitizen.out.success" )
342
+
343
+ commands .Commit (config , {"allow_empty" : True })()
344
+
345
+ commit_mock .assert_called_with (
346
+ "feat: user created\n \n closes #21" , args = "--allow-empty"
347
+ )
348
+ success_mock .assert_called_once ()
349
+
350
+
351
+ @pytest .mark .usefixtures ("staging_is_clean" )
352
+ def test_commit_with_signoff_and_allow_empty (config , mocker : MockFixture ):
353
+ prompt_mock = mocker .patch ("questionary.prompt" )
354
+ prompt_mock .return_value = {
355
+ "prefix" : "feat" ,
356
+ "subject" : "user created" ,
357
+ "scope" : "" ,
358
+ "is_breaking_change" : False ,
359
+ "body" : "closes #21" ,
360
+ "footer" : "" ,
361
+ }
362
+
363
+ commit_mock = mocker .patch ("commitizen.git.commit" )
364
+ commit_mock .return_value = cmd .Command ("success" , "" , b"" , b"" , 0 )
365
+ success_mock = mocker .patch ("commitizen.out.success" )
366
+
367
+ commands .Commit (config , {"allow_empty" : True , "signoff" : True })()
368
+
369
+ commit_mock .assert_called_with (
370
+ "feat: user created\n \n closes #21" , args = "-s --allow-empty"
371
+ )
372
+ success_mock .assert_called_once ()
373
+
374
+
327
375
@pytest .mark .usefixtures ("staging_is_clean" )
328
376
def test_commit_when_customized_expected_raised (config , mocker : MockFixture , capsys ):
329
377
_err = ValueError ()
0 commit comments