@@ -433,39 +433,54 @@ mod test {
433433 use std:: fs:: File ;
434434 use std:: io:: Cursor ;
435435 use std:: io:: prelude:: * ;
436+ use std:: path:: PathBuf ;
436437
437438 fn object ( size : u32 ) -> Vec < u8 > {
438439 ( 0 ..size) . map ( |_| 33 ) . collect ( )
439440 }
440441
442+ fn etag_test_path ( test_name : & str ) -> PathBuf {
443+ let mut path = std:: env:: temp_dir ( ) ;
444+ let unique = std:: time:: SystemTime :: now ( )
445+ . duration_since ( std:: time:: UNIX_EPOCH )
446+ . unwrap ( )
447+ . as_nanos ( ) ;
448+
449+ path. push ( format ! (
450+ "rust-s3-{test_name}-{}-{unique}" ,
451+ std:: process:: id( )
452+ ) ) ;
453+ path
454+ }
455+
441456 #[ test]
442457 fn test_etag_large_file ( ) {
443- let path = "test_etag" ;
444- std:: fs:: remove_file ( path) . unwrap_or ( ( ) ) ;
458+ let path = etag_test_path ( "etag-large-file" ) ;
459+ std:: fs:: remove_file ( & path) . unwrap_or ( ( ) ) ;
445460 let test: Vec < u8 > = object ( 10_000_000 ) ;
446461
447- let mut file = File :: create ( path) . unwrap ( ) ;
462+ let mut file = File :: create ( & path) . unwrap ( ) ;
448463 file. write_all ( & test) . unwrap ( ) ;
449464
450- let etag = etag_for_path ( path) . unwrap ( ) ;
465+ let etag = etag_for_path ( & path) . unwrap ( ) ;
451466
452- std:: fs:: remove_file ( path) . unwrap_or ( ( ) ) ;
467+ std:: fs:: remove_file ( & path) . unwrap_or ( ( ) ) ;
453468
454469 assert_eq ! ( etag, "e438487f09f09c042b2de097765e5ac2-2" ) ;
455470 }
456471
457472 #[ test]
458473 fn test_etag_small_file ( ) {
459- let path = "test_etag" ;
460- std:: fs:: remove_file ( path) . unwrap_or ( ( ) ) ;
474+ let path = etag_test_path ( "etag-small-file" ) ;
475+ std:: fs:: remove_file ( & path) . unwrap_or ( ( ) ) ;
461476 let test: Vec < u8 > = object ( 1000 ) ;
462477
463- let mut file = File :: create ( path) . unwrap ( ) ;
478+ let mut file = File :: create ( & path) . unwrap ( ) ;
464479 file. write_all ( & test) . unwrap ( ) ;
465480
466- let etag = etag_for_path ( path) . unwrap ( ) ;
481+ let etag = etag_for_path ( & path) . unwrap ( ) ;
467482
468- std:: fs:: remove_file ( path) . unwrap_or ( ( ) ) ;
483+ std:: fs:: remove_file ( & path) . unwrap_or ( ( ) ) ;
469484
470485 assert_eq ! ( etag, "8122ef1c2b2331f7986349560248cf56" ) ;
471486 }
0 commit comments