mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
Make sure to sync on file-io.rs tokio test
Tokio `AsyncWriteExt::write` doesn't actually ensure that the contents have written, it just *starts* the write operation. To ensure that the file has actually been written, we need to `sync_all` first.
This commit is contained in:
@@ -21,6 +21,7 @@ async fn test_create_and_write() -> io::Result<()> {
|
||||
|
||||
// Write 10 bytes to the file.
|
||||
file.write_all(b"some bytes").await?;
|
||||
file.sync_all().await?; // tokio doesn't necessarily complete writes until you sync.
|
||||
assert_eq!(file.metadata().await.unwrap().len(), 10);
|
||||
|
||||
remove_file(&path).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user