@@ -24,23 +24,25 @@ fn get_compressed_file_content() {
2424 assert_eq ! ( written, 18 , "Uncompressed bytes count did not match" ) ;
2525}
2626
27- #[ async_std :: test]
27+ #[ test]
2828#[ cfg( feature = "futures_support" ) ]
29- async fn get_compressed_file_content_futures ( ) {
30- let mut source = async_std:: fs:: File :: open ( "tests/fixtures/file.txt.gz" )
31- . await
32- . unwrap ( ) ;
33- let mut target = Vec :: default ( ) ;
29+ fn get_compressed_file_content_futures ( ) {
30+ smol:: block_on ( async {
31+ let mut source = smol:: fs:: File :: open ( "tests/fixtures/file.txt.gz" )
32+ . await
33+ . unwrap ( ) ;
34+ let mut target = Vec :: default ( ) ;
3435
35- let written = futures_support:: uncompress_data ( & mut source, & mut target)
36- . await
37- . expect ( "Failed to uncompress the file" ) ;
38- assert_eq ! (
39- String :: from_utf8_lossy( & target) ,
40- "some_file_content\n " ,
41- "Uncompressed file did not match" ,
42- ) ;
43- assert_eq ! ( written, 18 , "Uncompressed bytes count did not match" ) ;
36+ let written = futures_support:: uncompress_data ( & mut source, & mut target)
37+ . await
38+ . expect ( "Failed to uncompress the file" ) ;
39+ assert_eq ! (
40+ String :: from_utf8_lossy( & target) ,
41+ "some_file_content\n " ,
42+ "Uncompressed file did not match" ,
43+ ) ;
44+ assert_eq ! ( written, 18 , "Uncompressed bytes count did not match" ) ;
45+ } ) ;
4446}
4547
4648#[ tokio:: test]
@@ -92,24 +94,26 @@ fn get_a_file_from_7z() {
9294 assert_eq ! ( written, 14 , "Uncompressed bytes count did not match" ) ;
9395}
9496
95- #[ async_std :: test]
97+ #[ test]
9698#[ cfg( feature = "futures_support" ) ]
97- async fn get_a_file_from_tar_futures ( ) {
98- let mut source = async_std:: fs:: File :: open ( "tests/fixtures/tree.tar" )
99- . await
100- . unwrap ( ) ;
101- let mut target = Vec :: default ( ) ;
102-
103- let written =
104- futures_support:: uncompress_archive_file ( & mut source, & mut target, "tree/branch2/leaf" )
99+ fn get_a_file_from_tar_futures ( ) {
100+ smol:: block_on ( async {
101+ let mut source = smol:: fs:: File :: open ( "tests/fixtures/tree.tar" )
105102 . await
106- . expect ( "Failed to get the file" ) ;
107- assert_eq ! (
108- String :: from_utf8_lossy( & target) ,
109- "Goodbye World\n " ,
110- "Uncompressed file did not match" ,
111- ) ;
112- assert_eq ! ( written, 14 , "Uncompressed bytes count did not match" ) ;
103+ . unwrap ( ) ;
104+ let mut target = Vec :: default ( ) ;
105+
106+ let written =
107+ futures_support:: uncompress_archive_file ( & mut source, & mut target, "tree/branch2/leaf" )
108+ . await
109+ . expect ( "Failed to get the file" ) ;
110+ assert_eq ! (
111+ String :: from_utf8_lossy( & target) ,
112+ "Goodbye World\n " ,
113+ "Uncompressed file did not match" ,
114+ ) ;
115+ assert_eq ! ( written, 14 , "Uncompressed bytes count did not match" ) ;
116+ } ) ;
113117}
114118
115119#[ tokio:: test]
@@ -149,24 +153,26 @@ fn successfully_list_archive_files() {
149153 ) ;
150154}
151155
152- #[ async_std :: test]
156+ #[ test]
153157#[ cfg( feature = "futures_support" ) ]
154- async fn successfully_list_archive_files_futures ( ) {
155- let source = async_std:: fs:: File :: open ( "tests/fixtures/tree.tar" )
156- . await
157- . unwrap ( ) ;
158+ fn successfully_list_archive_files_futures ( ) {
159+ smol:: block_on ( async {
160+ let source = smol:: fs:: File :: open ( "tests/fixtures/tree.tar" )
161+ . await
162+ . unwrap ( ) ;
158163
159- assert_eq ! (
160- futures_support:: list_archive_files( source) . await . unwrap( ) ,
161- vec![
162- "tree/" . to_string( ) ,
163- "tree/branch1/" . to_string( ) ,
164- "tree/branch1/leaf" . to_string( ) ,
165- "tree/branch2/" . to_string( ) ,
166- "tree/branch2/leaf" . to_string( ) ,
167- ] ,
168- "file list inside the archive did not match"
169- ) ;
164+ assert_eq ! (
165+ futures_support:: list_archive_files( source) . await . unwrap( ) ,
166+ vec![
167+ "tree/" . to_string( ) ,
168+ "tree/branch1/" . to_string( ) ,
169+ "tree/branch1/leaf" . to_string( ) ,
170+ "tree/branch2/" . to_string( ) ,
171+ "tree/branch2/leaf" . to_string( ) ,
172+ ] ,
173+ "file list inside the archive did not match"
174+ ) ;
175+ } ) ;
170176}
171177
172178#[ tokio:: test]
@@ -429,31 +435,33 @@ fn uncompress_same_file_not_preserve_owner() {
429435 . expect ( "Failed to uncompress the file" ) ;
430436}
431437
432- #[ async_std :: test]
438+ #[ test]
433439#[ cfg( feature = "futures_support" ) ]
434- async fn uncompress_same_file_not_preserve_owner_futures ( ) {
435- futures_support:: uncompress_archive (
436- & mut async_std:: fs:: File :: open ( "tests/fixtures/tree.tar" )
437- . await
438- . unwrap ( ) ,
439- tempfile:: TempDir :: new ( )
440- . expect ( "Failed to create the tmp directory" )
441- . path ( ) ,
442- Ownership :: Ignore ,
443- )
444- . await
445- . expect ( "Failed to uncompress the file" ) ;
446- futures_support:: uncompress_archive (
447- & mut async_std:: fs:: File :: open ( "tests/fixtures/tree.tar" )
448- . await
449- . unwrap ( ) ,
450- tempfile:: TempDir :: new ( )
451- . expect ( "Failed to create the tmp directory" )
452- . path ( ) ,
453- Ownership :: Ignore ,
454- )
455- . await
456- . expect ( "Failed to uncompress the file" ) ;
440+ fn uncompress_same_file_not_preserve_owner_futures ( ) {
441+ smol:: block_on ( async {
442+ futures_support:: uncompress_archive (
443+ & mut smol:: fs:: File :: open ( "tests/fixtures/tree.tar" )
444+ . await
445+ . unwrap ( ) ,
446+ tempfile:: TempDir :: new ( )
447+ . expect ( "Failed to create the tmp directory" )
448+ . path ( ) ,
449+ Ownership :: Ignore ,
450+ )
451+ . await
452+ . expect ( "Failed to uncompress the file" ) ;
453+ futures_support:: uncompress_archive (
454+ & mut smol:: fs:: File :: open ( "tests/fixtures/tree.tar" )
455+ . await
456+ . unwrap ( ) ,
457+ tempfile:: TempDir :: new ( )
458+ . expect ( "Failed to create the tmp directory" )
459+ . path ( ) ,
460+ Ownership :: Ignore ,
461+ )
462+ . await
463+ . expect ( "Failed to uncompress the file" ) ;
464+ } ) ;
457465}
458466
459467#[ tokio:: test]
@@ -494,19 +502,21 @@ fn uncompress_truncated_archive() {
494502 ) ) ;
495503}
496504
497- #[ async_std :: test]
505+ #[ test]
498506#[ cfg( feature = "futures_support" ) ]
499- async fn uncompress_truncated_archive_futures ( ) {
500- assert ! ( matches!(
501- futures_support:: uncompress_data(
502- async_std:: fs:: File :: open( "tests/fixtures/truncated.log.gz" )
503- . await
504- . unwrap( ) ,
505- Vec :: new( )
506- )
507- . await ,
508- Err ( Error :: Unknown )
509- ) ) ;
507+ fn uncompress_truncated_archive_futures ( ) {
508+ smol:: block_on ( async {
509+ assert ! ( matches!(
510+ futures_support:: uncompress_data(
511+ smol:: fs:: File :: open( "tests/fixtures/truncated.log.gz" )
512+ . await
513+ . unwrap( ) ,
514+ Vec :: new( )
515+ )
516+ . await ,
517+ Err ( Error :: Unknown )
518+ ) ) ;
519+ } ) ;
510520}
511521
512522#[ tokio:: test]
0 commit comments