@@ -454,6 +454,53 @@ mod tests {
454454 Ok ( ( ) )
455455 }
456456
457+ #[ test]
458+ fn save_reports_read_errors_for_existing_config_directory ( ) -> Result < ( ) > {
459+ let temp_home = TempHome :: new ( ) ?;
460+ let config_path = temp_home. path . join ( ".config/gitlogue/config.toml" ) ;
461+
462+ fs:: create_dir_all ( & config_path) ?;
463+
464+ let error = sample_config ( ) . save ( ) . unwrap_err ( ) . to_string ( ) ;
465+
466+ assert ! ( error. contains( "Failed to read config file" ) ) ;
467+ assert ! ( error. contains( & config_path. display( ) . to_string( ) ) ) ;
468+
469+ Ok ( ( ) )
470+ }
471+
472+ #[ test]
473+ fn config_path_reports_create_dir_errors_with_target_path ( ) -> Result < ( ) > {
474+ let temp_home = TempHome :: new ( ) ?;
475+ let config_dir = temp_home. path . join ( ".config/gitlogue" ) ;
476+
477+ fs:: create_dir_all ( temp_home. path . join ( ".config" ) ) ?;
478+ fs:: write ( & config_dir, "occupied" ) ?;
479+
480+ let error = Config :: config_path ( ) . unwrap_err ( ) . to_string ( ) ;
481+
482+ assert ! ( error. contains( "Failed to create config directory" ) ) ;
483+ assert ! ( error. contains( & config_dir. display( ) . to_string( ) ) ) ;
484+
485+ Ok ( ( ) )
486+ }
487+
488+ #[ test]
489+ fn themes_dir_reports_create_dir_errors_with_target_path ( ) -> Result < ( ) > {
490+ let temp_home = TempHome :: new ( ) ?;
491+ let themes_dir = temp_home. path . join ( ".config/gitlogue/themes" ) ;
492+
493+ fs:: create_dir_all ( temp_home. path . join ( ".config/gitlogue" ) ) ?;
494+ fs:: write ( & themes_dir, "occupied" ) ?;
495+
496+ let error = Config :: themes_dir ( ) . unwrap_err ( ) . to_string ( ) ;
497+
498+ assert ! ( error. contains( "Failed to create themes directory" ) ) ;
499+ assert ! ( error. contains( & themes_dir. display( ) . to_string( ) ) ) ;
500+
501+ Ok ( ( ) )
502+ }
503+
457504 #[ test]
458505 fn themes_dir_is_created_under_the_config_home ( ) -> Result < ( ) > {
459506 let temp_home = TempHome :: new ( ) ?;
0 commit comments