@@ -9,12 +9,10 @@ fn select_custom_config_path_test() -> Result<()> {
99
1010 let config_path = Some ( config_file. path ( ) . to_owned ( ) ) ;
1111 let selected_config_path = select_custom_config_path ( config_path. clone ( ) ) ?;
12-
1312 assert_eq ! ( config_path. unwrap( ) . to_str( ) , selected_config_path. to_str( ) ) ;
1413
1514 let config_path_default = dirs:: config_dir ( ) . unwrap ( ) . join ( "commit/commit.json" ) ;
1615 let selected_config_path = select_custom_config_path ( None ) ?;
17-
1816 assert_eq ! ( selected_config_path. to_str( ) , config_path_default. to_str( ) ) ;
1917
2018 let selected_config_path = select_custom_config_path ( Some ( PathBuf :: new ( ) ) ) ;
@@ -24,20 +22,24 @@ fn select_custom_config_path_test() -> Result<()> {
2422 }
2523 Ok ( ( ) )
2624}
25+
2726#[ test]
2827fn get_config_path_test ( ) -> Result < ( ) > {
2928 let temp_dir = assert_fs:: TempDir :: new ( ) ?;
3029 let config_file = dirs:: config_dir ( ) . unwrap ( ) . join ( "commit/commit.json" ) ;
3130 let config_path = get_config_path ( ) ;
3231 assert_eq ! ( config_file. to_str( ) , config_path. unwrap( ) . to_str( ) ) ;
32+
3333 let last_current_dir = std:: env:: current_dir ( ) ?;
3434 std:: env:: set_current_dir ( temp_dir. to_owned ( ) ) ?;
3535 let config_file = temp_dir. child ( "commit.json" ) ;
3636 config_file. touch ( ) ?;
3737 assert_eq ! ( config_file. to_str( ) , get_config_path( ) ?. to_str( ) ) ;
38+
3839 std:: env:: set_current_dir ( last_current_dir) ?;
3940 Ok ( ( ) )
4041}
42+
4143#[ test]
4244fn get_config_path_content_test ( ) -> Result < ( ) > {
4345 let temp_dir = assert_fs:: TempDir :: new ( ) ?;
@@ -46,12 +48,14 @@ fn get_config_path_content_test() -> Result<()> {
4648 let config_path = config_file. path ( ) ;
4749 let content = get_config_path_content ( config_path) ?;
4850 assert_eq ! ( content, "" ) ;
51+
4952 let expected = include_str ! ( "../../commit-default.json" ) ;
5053 config_file. write_str ( expected) ?;
5154 let content = get_config_path_content ( config_path) ?;
5255 assert_eq ! ( content, expected) ;
5356 Ok ( ( ) )
5457}
58+
5559#[ test]
5660fn get_pattern_test ( ) -> Result < ( ) > {
5761 let pattern = get_pattern ( None ) ?;
0 commit comments