File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,6 @@ impl File {
154154 let path = path. as_ref ( ) . to_owned ( ) ;
155155 let file = spawn_blocking ( move || {
156156 std:: fs:: File :: create ( & path)
157- . context ( || format ! ( "could not create `{}`" , path. display( ) ) )
158157 } )
159158 . await ?;
160159 Ok ( File :: new ( file, true ) )
@@ -903,4 +902,15 @@ mod tests {
903902 assert_eq ! ( len as u64 , file. metadata( ) . await . unwrap( ) . len( ) ) ;
904903 } ) ;
905904 }
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+ }
906916}
You can’t perform that action at this time.
0 commit comments