We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 7e455db + 6f61c9d commit f201f4aCopy full SHA for f201f4a
src/fs/file.rs
@@ -154,7 +154,6 @@ impl File {
154
let path = path.as_ref().to_owned();
155
let file = spawn_blocking(move || {
156
std::fs::File::create(&path)
157
- .context(|| format!("could not create `{}`", path.display()))
158
})
159
.await?;
160
Ok(File::new(file, true))
@@ -903,4 +902,15 @@ mod tests {
903
902
assert_eq!(len as u64, file.metadata().await.unwrap().len());
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
+ }
916
0 commit comments