@@ -6,9 +6,9 @@ use collab_importer::zip_tool::async_zip::async_unzip;
66use collab_importer:: zip_tool:: sync_zip:: sync_unzip;
77use tempfile:: tempdir;
88use tokio_util:: compat:: TokioAsyncReadCompatExt ;
9- use zip:: write:: FileOptions ;
109use zip:: CompressionMethod ;
1110use zip:: ZipWriter ;
11+ use zip:: write:: FileOptions ;
1212
1313const ROOT_DIR : & str = "ExportBlock-7365b89b" ;
1414const FALLBACK_DIR : & str = "fallback" ;
@@ -22,7 +22,11 @@ fn sync_unzip_preserves_root_directory_with_nested_zip() -> Result<()> {
2222 let output_dir = temp. path ( ) . join ( "output" ) ;
2323 std:: fs:: create_dir_all ( & output_dir) ?;
2424
25- let unzip_file = sync_unzip ( zip_path. clone ( ) , output_dir. clone ( ) , Some ( FALLBACK_DIR . to_string ( ) ) ) ?;
25+ let unzip_file = sync_unzip (
26+ zip_path. clone ( ) ,
27+ output_dir. clone ( ) ,
28+ Some ( FALLBACK_DIR . to_string ( ) ) ,
29+ ) ?;
2630
2731 let expected_root = output_dir. join ( ROOT_DIR ) ;
2832 assert_eq ! ( unzip_file. dir_name, ROOT_DIR ) ;
@@ -41,7 +45,11 @@ fn sync_unzip_falls_back_when_root_directory_missing() -> Result<()> {
4145 let output_dir = temp. path ( ) . join ( "output" ) ;
4246 std:: fs:: create_dir_all ( & output_dir) ?;
4347
44- let unzip_file = sync_unzip ( zip_path. clone ( ) , output_dir. clone ( ) , Some ( FALLBACK_DIR . to_string ( ) ) ) ?;
48+ let unzip_file = sync_unzip (
49+ zip_path. clone ( ) ,
50+ output_dir. clone ( ) ,
51+ Some ( FALLBACK_DIR . to_string ( ) ) ,
52+ ) ?;
4553
4654 assert_eq ! ( unzip_file. dir_name, FALLBACK_DIR ) ;
4755 assert_eq ! ( unzip_file. unzip_dir, output_dir) ;
@@ -63,12 +71,21 @@ async fn async_unzip_preserves_root_directory_with_nested_zip() -> Result<()> {
6371 let output_dir = temp. path ( ) . join ( "async_output" ) ;
6472 tokio:: fs:: create_dir_all ( & output_dir) . await ?;
6573
66- let unzip_file = async_unzip ( zip_reader, output_dir. clone ( ) , Some ( FALLBACK_DIR . to_string ( ) ) ) . await ?;
74+ let unzip_file = async_unzip (
75+ zip_reader,
76+ output_dir. clone ( ) ,
77+ Some ( FALLBACK_DIR . to_string ( ) ) ,
78+ )
79+ . await ?;
6780
6881 let expected_root = output_dir. join ( ROOT_DIR ) ;
6982 assert_eq ! ( unzip_file. file_name, ROOT_DIR ) ;
7083 assert_eq ! ( unzip_file. unzip_dir_path, expected_root) ;
71- assert ! ( tokio:: fs:: metadata( unzip_file. unzip_dir_path. clone( ) ) . await ?. is_dir( ) ) ;
84+ assert ! (
85+ tokio:: fs:: metadata( unzip_file. unzip_dir_path. clone( ) )
86+ . await ?
87+ . is_dir( )
88+ ) ;
7289
7390 Ok ( ( ) )
7491}
@@ -86,11 +103,20 @@ async fn async_unzip_falls_back_when_root_directory_missing() -> Result<()> {
86103 let output_dir = temp. path ( ) . join ( "async_output" ) ;
87104 tokio:: fs:: create_dir_all ( & output_dir) . await ?;
88105
89- let unzip_file = async_unzip ( zip_reader, output_dir. clone ( ) , Some ( FALLBACK_DIR . to_string ( ) ) ) . await ?;
106+ let unzip_file = async_unzip (
107+ zip_reader,
108+ output_dir. clone ( ) ,
109+ Some ( FALLBACK_DIR . to_string ( ) ) ,
110+ )
111+ . await ?;
90112
91113 assert_eq ! ( unzip_file. file_name, FALLBACK_DIR ) ;
92114 assert_eq ! ( unzip_file. unzip_dir_path, output_dir) ;
93- assert ! ( tokio:: fs:: metadata( & unzip_file. unzip_dir_path) . await ?. is_dir( ) ) ;
115+ assert ! (
116+ tokio:: fs:: metadata( & unzip_file. unzip_dir_path)
117+ . await ?
118+ . is_dir( )
119+ ) ;
94120
95121 Ok ( ( ) )
96122}
0 commit comments