@@ -339,6 +339,36 @@ mod tests {
339339 Ok ( ( ) )
340340 }
341341
342+ #[ test]
343+ fn load_accepts_legacy_loop_playback_key ( ) -> Result < ( ) > {
344+ let _temp_home = TempHome :: new ( ) ?;
345+ let config_path = Config :: config_path ( ) ?;
346+
347+ fs:: write ( & config_path, "loop_playback = true\n " ) ?;
348+
349+ let config = Config :: load ( ) ?;
350+
351+ assert ! ( config. loop_playback) ;
352+ assert_eq ! ( config. theme, "tokyo-night" ) ;
353+
354+ Ok ( ( ) )
355+ }
356+
357+ #[ test]
358+ fn load_reports_parse_errors_with_config_path ( ) -> Result < ( ) > {
359+ let _temp_home = TempHome :: new ( ) ?;
360+ let config_path = Config :: config_path ( ) ?;
361+
362+ fs:: write ( & config_path, "theme = [\n " ) ?;
363+
364+ let error = Config :: load ( ) . unwrap_err ( ) . to_string ( ) ;
365+
366+ assert ! ( error. contains( "Failed to parse config file" ) ) ;
367+ assert ! ( error. contains( & config_path. display( ) . to_string( ) ) ) ;
368+
369+ Ok ( ( ) )
370+ }
371+
342372 #[ test]
343373 fn save_creates_commented_config_and_round_trips_values ( ) -> Result < ( ) > {
344374 let _temp_home = TempHome :: new ( ) ?;
@@ -360,6 +390,22 @@ mod tests {
360390 Ok ( ( ) )
361391 }
362392
393+ #[ test]
394+ fn save_writes_empty_arrays_for_default_collections ( ) -> Result < ( ) > {
395+ let _temp_home = TempHome :: new ( ) ?;
396+ let config = Config :: default ( ) ;
397+ let config_path = Config :: config_path ( ) ?;
398+
399+ config. save ( ) ?;
400+
401+ let contents = fs:: read_to_string ( & config_path) ?;
402+
403+ assert ! ( contents. contains( "ignore_patterns = []" ) ) ;
404+ assert ! ( contents. contains( "speed_rules = []" ) ) ;
405+
406+ Ok ( ( ) )
407+ }
408+
363409 #[ test]
364410 fn save_updates_existing_config_without_dropping_comments ( ) -> Result < ( ) > {
365411 let _temp_home = TempHome :: new ( ) ?;
@@ -393,6 +439,21 @@ mod tests {
393439 Ok ( ( ) )
394440 }
395441
442+ #[ test]
443+ fn save_reports_parse_errors_for_existing_invalid_config ( ) -> Result < ( ) > {
444+ let _temp_home = TempHome :: new ( ) ?;
445+ let config_path = Config :: config_path ( ) ?;
446+
447+ fs:: write ( & config_path, "theme = [\n " ) ?;
448+
449+ let error = sample_config ( ) . save ( ) . unwrap_err ( ) . to_string ( ) ;
450+
451+ assert ! ( error. contains( "Failed to parse config file" ) ) ;
452+ assert ! ( error. contains( & config_path. display( ) . to_string( ) ) ) ;
453+
454+ Ok ( ( ) )
455+ }
456+
396457 #[ test]
397458 fn themes_dir_is_created_under_the_config_home ( ) -> Result < ( ) > {
398459 let temp_home = TempHome :: new ( ) ?;
0 commit comments