File tree 1 file changed +11
-1
lines changed
1 file changed +11
-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,15 @@ 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
+ let file_name = Path :: new ( "/tmp/does_not_exist/test" ) ;
909
+ let expect = std:: fs:: File :: create ( file_name) . unwrap_err ( ) ;
910
+
911
+ crate :: task:: block_on ( async move {
912
+ let actual = File :: create ( file_name) . await . unwrap_err ( ) ;
913
+ assert_eq ! ( format!( "{}" , expect) , format!( "{}" , actual) ) ;
914
+ } )
915
+ }
906
916
}
You can’t perform that action at this time.
0 commit comments