@@ -208,6 +208,21 @@ fn theme_subcommands_list_and_set_default_theme() -> Result<()> {
208208 Ok ( ( ) )
209209}
210210
211+ #[ test]
212+ fn theme_set_rejects_unknown_theme_without_writing_config ( ) -> Result < ( ) > {
213+ let home = TempHome :: new ( ) ?;
214+
215+ let output = run_command ( command_with_home ( & home) . args ( [ "theme" , "set" , "missing-theme" ] ) ) ?;
216+
217+ assert ! ( !output. status. success( ) ) ;
218+ assert_eq ! ( stdout( & output) , "" ) ;
219+ assert ! ( stderr( & output) . contains( "Unknown theme: missing-theme" ) ) ;
220+ assert ! ( stderr( & output) . contains( "Available themes:" ) ) ;
221+ assert ! ( !home. config_path( ) . exists( ) ) ;
222+
223+ Ok ( ( ) )
224+ }
225+
211226#[ test]
212227fn diff_subcommand_reports_no_changes_for_clean_repo ( ) -> Result < ( ) > {
213228 let repo = TestRepo :: new ( ) ?;
@@ -244,6 +259,30 @@ fn diff_subcommand_with_staged_changes_fails_only_after_ui_startup_without_tty()
244259 Ok ( ( ) )
245260}
246261
262+ #[ test]
263+ fn diff_subcommand_with_invalid_theme_fails_before_ui_startup ( ) -> Result < ( ) > {
264+ let repo = TestRepo :: new ( ) ?;
265+ repo. commit_file ( "src/lib.rs" , "fn clean() {}\n " , "initial" , 1 ) ?;
266+ repo. write_file ( "src/lib.rs" , "fn staged() {}\n " ) ?;
267+ repo. stage_file ( "src/lib.rs" ) ?;
268+
269+ let output = run_command ( gitlogue_command ( ) . args ( [
270+ "--path" ,
271+ repo_path ( & repo) . to_str ( ) . unwrap ( ) ,
272+ "diff" ,
273+ "--theme" ,
274+ "missing-theme" ,
275+ ] ) ) ?;
276+
277+ assert ! ( !output. status. success( ) ) ;
278+ assert_eq ! ( stdout( & output) , "" ) ;
279+ assert ! ( stderr( & output) . contains( "Unknown theme: missing-theme" ) ) ;
280+ assert ! ( stderr( & output) . contains( "Available themes:" ) ) ;
281+ assert ! ( !stderr( & output) . contains( "No such device or address" ) ) ;
282+
283+ Ok ( ( ) )
284+ }
285+
247286#[ test]
248287fn default_playback_fails_only_after_ui_startup_without_tty ( ) -> Result < ( ) > {
249288 let repo = TestRepo :: new ( ) ?;
@@ -259,6 +298,27 @@ fn default_playback_fails_only_after_ui_startup_without_tty() -> Result<()> {
259298 Ok ( ( ) )
260299}
261300
301+ #[ test]
302+ fn default_playback_with_invalid_theme_fails_before_ui_startup ( ) -> Result < ( ) > {
303+ let repo = TestRepo :: new ( ) ?;
304+ repo. commit_file ( "src/main.rs" , "fn main() {}\n " , "initial" , 1 ) ?;
305+
306+ let output = run_command ( gitlogue_command ( ) . args ( [
307+ "--path" ,
308+ repo_path ( & repo) . to_str ( ) . unwrap ( ) ,
309+ "--theme" ,
310+ "missing-theme" ,
311+ ] ) ) ?;
312+
313+ assert ! ( !output. status. success( ) ) ;
314+ assert_eq ! ( stdout( & output) , "" ) ;
315+ assert ! ( stderr( & output) . contains( "Unknown theme: missing-theme" ) ) ;
316+ assert ! ( stderr( & output) . contains( "Available themes:" ) ) ;
317+ assert ! ( !stderr( & output) . contains( "No such device or address" ) ) ;
318+
319+ Ok ( ( ) )
320+ }
321+
262322#[ test]
263323fn default_playback_quits_cleanly_in_pseudo_tty ( ) -> Result < ( ) > {
264324 let home = TempHome :: new ( ) ?;
0 commit comments