@@ -109,6 +109,32 @@ def test_commit_command_with_dry_run_option(config, mocker: MockFixture):
109
109
commit_cmd ()
110
110
111
111
112
+ @pytest .mark .usefixtures ("staging_is_clean" )
113
+ def test_commit_command_with_write_message_to_file_option (
114
+ config , tmp_path , mocker : MockFixture
115
+ ):
116
+ tmp_file = tmp_path / "message"
117
+
118
+ prompt_mock = mocker .patch ("questionary.prompt" )
119
+ prompt_mock .return_value = {
120
+ "prefix" : "feat" ,
121
+ "subject" : "user created" ,
122
+ "scope" : "" ,
123
+ "is_breaking_change" : False ,
124
+ "body" : "" ,
125
+ "footer" : "" ,
126
+ }
127
+
128
+ commit_mock = mocker .patch ("commitizen.git.commit" )
129
+ commit_mock .return_value = cmd .Command ("success" , "" , b"" , b"" , 0 )
130
+ success_mock = mocker .patch ("commitizen.out.success" )
131
+
132
+ commands .Commit (config , {"write_message_to_file" : str (tmp_file )})()
133
+ success_mock .assert_called_once ()
134
+ assert tmp_file .exists ()
135
+ assert tmp_file .read_text () == "feat: user created"
136
+
137
+
112
138
@pytest .mark .usefixtures ("staging_is_clean" )
113
139
def test_commit_command_with_signoff_option (config , mocker : MockFixture ):
114
140
prompt_mock = mocker .patch ("questionary.prompt" )
0 commit comments