Debian Codegraph @

third_party/rust/tokio/tests/fs_remove_file.rs

raw
1 #![warn(rust_2018_idioms)]
2 #![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
3
4 use tempfile::tempdir;
5 use tokio::fs;
6
7 #[tokio::test]
8 async fn remove_file() {
9 let temp_dir = tempdir().unwrap();
10
11 let file_path = temp_dir.path().join("a.txt");
12
13 fs::write(&file_path, b"Hello File!").await.unwrap();
14
15 assert!(fs::try_exists(&file_path).await.unwrap());
16
17 fs::remove_file(&file_path).await.unwrap();
18
19 // should no longer exist
20 match fs::try_exists(file_path).await {
21 Ok(exists) => assert!(!exists),
22 Err(_) => println!("ignored try_exists error after remove_file"),
23 };
24 }