File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,6 @@ impl File {
154
154
let path = path. as_ref ( ) . to_owned ( ) ;
155
155
let file = spawn_blocking ( move || {
156
156
std:: fs:: File :: create ( & path)
157
- . context ( || format ! ( "could not create `{}`" , path. display( ) ) )
158
157
} )
159
158
. await ?;
160
159
Ok ( File :: new ( file, true ) )
@@ -903,4 +902,17 @@ mod tests {
903
902
assert_eq ! ( len as u64 , file. metadata( ) . await . unwrap( ) . len( ) ) ;
904
903
} ) ;
905
904
}
905
+
906
+ #[ test]
907
+ fn async_file_create_error ( ) {
908
+ crate :: task:: block_on ( async move {
909
+ let file_name = Path :: new ( "/tmp/does_not_exist/test" ) ;
910
+ match File :: create ( file_name) . await {
911
+ Ok ( _) => ( ) ,
912
+ Err ( e) => {
913
+ assert_eq ! ( "No such file or directory (os error 2)" , format!( "{}" , e) ) ;
914
+ }
915
+ } ;
916
+ } )
917
+ }
906
918
}
You can’t perform that action at this time.
0 commit comments