1 | #![warn (rust_2018_idioms)] |
2 | #![cfg (all(feature = "full" , not(target_os = "wasi" )))] // WASI does not support all fs operations |
3 | #![cfg (windows)] |
4 | |
5 | use tempfile::tempdir; |
6 | use tokio::fs; |
7 | |
8 | #[tokio::test ] |
9 | async fn symlink_file_windows() { |
10 | const FILE_NAME: &str = "abc.txt" ; |
11 | |
12 | let temp_dir = tempdir().unwrap(); |
13 | |
14 | let dir1 = temp_dir.path().join("a" ); |
15 | fs::create_dir(&dir1).await.unwrap(); |
16 | |
17 | let file1 = dir1.as_path().join(FILE_NAME); |
18 | fs::write(&file1, b"Hello File!" ).await.unwrap(); |
19 | |
20 | let dir2 = temp_dir.path().join("b" ); |
21 | fs::symlink_dir(&dir1, &dir2).await.unwrap(); |
22 | |
23 | fs::write(&file1, b"new data!" ).await.unwrap(); |
24 | |
25 | let file2 = dir2.as_path().join(FILE_NAME); |
26 | |
27 | let from = fs::read(&file1).await.unwrap(); |
28 | let to = fs::read(&file2).await.unwrap(); |
29 | |
30 | assert_eq!(from, to); |
31 | } |
32 | |