File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -392,6 +392,29 @@ def test_check_command_cli_overrides_config_message_length_limit(
392392 success_mock .assert_called_once ()
393393
394394
395+ def test_check_command_with_negative_cli_message_length_limit_raises (config ):
396+ with pytest .raises (InvalidCommandArgumentError ):
397+ commands .Check (
398+ config = config ,
399+ arguments = {
400+ "message" : "fix(scope): some commit message" ,
401+ "message_length_limit" : - 1 ,
402+ },
403+ )
404+
405+
406+ def test_check_command_with_negative_config_message_length_limit_raises (config ):
407+ config .settings ["message_length_limit" ] = - 1
408+ with pytest .raises (InvalidCommandArgumentError ):
409+ commands .Check (
410+ config = config ,
411+ arguments = {
412+ "message" : "fix(scope): some commit message" ,
413+ "message_length_limit" : None ,
414+ },
415+ )
416+
417+
395418class ValidationCz (BaseCommitizen ):
396419 def questions (self ) -> list [CzQuestion ]:
397420 return [
Original file line number Diff line number Diff line change 1212 CommitMessageLengthExceededError ,
1313 CustomError ,
1414 DryRunExit ,
15+ InvalidCommandArgumentError ,
1516 NoAnswersError ,
1617 NoCommitBackupError ,
1718 NotAGitProjectError ,
@@ -403,3 +404,14 @@ def test_commit_message_length_cli_zero_disables_limit(
403404 )
404405 commands .Commit (config , {"message_length_limit" : 0 })()
405406 success_mock .assert_called_once ()
407+
408+
409+ def test_commit_message_length_cli_negative_raises (config ):
410+ with pytest .raises (InvalidCommandArgumentError ):
411+ commands .Commit (config , {"message_length_limit" : - 1 })
412+
413+
414+ def test_commit_message_length_config_negative_raises_when_cli_unset (config ):
415+ config .settings ["message_length_limit" ] = - 1
416+ with pytest .raises (InvalidCommandArgumentError ):
417+ commands .Commit (config , {"message_length_limit" : None })
You can’t perform that action at this time.
0 commit comments