|
12 | 12 | NoAnswersError,
|
13 | 13 | NoCommitBackupError,
|
14 | 14 | NotAGitProjectError,
|
| 15 | + NotAllowed, |
15 | 16 | NothingToCommitError,
|
16 | 17 | )
|
17 | 18 |
|
@@ -135,6 +136,27 @@ def test_commit_command_with_write_message_to_file_option(
|
135 | 136 | assert tmp_file.read_text() == "feat: user created"
|
136 | 137 |
|
137 | 138 |
|
| 139 | +@pytest.mark.usefixtures("staging_is_clean") |
| 140 | +@pytest.mark.parametrize("message_file", [True, False, 0, 1]) |
| 141 | +def test_commit_command_with_invalid_write_message_to_file_option( |
| 142 | + config, message_file, mocker: MockFixture |
| 143 | +): |
| 144 | + prompt_mock = mocker.patch("questionary.prompt") |
| 145 | + prompt_mock.return_value = { |
| 146 | + "prefix": "feat", |
| 147 | + "subject": "user created", |
| 148 | + "scope": "", |
| 149 | + "is_breaking_change": False, |
| 150 | + "body": "", |
| 151 | + "footer": "", |
| 152 | + } |
| 153 | + |
| 154 | + with pytest.raises(NotAllowed): |
| 155 | + print(isinstance(message_file, str)) |
| 156 | + commit_cmd = commands.Commit(config, {"write_message_to_file": message_file}) |
| 157 | + commit_cmd() |
| 158 | + |
| 159 | + |
138 | 160 | @pytest.mark.usefixtures("staging_is_clean")
|
139 | 161 | def test_commit_command_with_signoff_option(config, mocker: MockFixture):
|
140 | 162 | prompt_mock = mocker.patch("questionary.prompt")
|
|
0 commit comments