From bc8dcdeb58dfca234d85b2a93a7a20af738f48a2 Mon Sep 17 00:00:00 2001 From: Thomas Whiteway Date: Fri, 6 Mar 2020 18:00:33 +0000 Subject: [PATCH] Add foo.txt and bar.txt to .gitignore (#2294) --- tokio/tests/fs_copy.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tokio/tests/fs_copy.rs b/tokio/tests/fs_copy.rs index e8c1b7a39..dc6c0d6f9 100644 --- a/tokio/tests/fs_copy.rs +++ b/tokio/tests/fs_copy.rs @@ -1,15 +1,21 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] +use tempfile::tempdir; use tokio::fs; #[tokio::test] async fn copy() { - fs::write("foo.txt", b"Hello File!").await.unwrap(); - fs::copy("foo.txt", "bar.txt").await.unwrap(); + let dir = tempdir().unwrap(); - let from = fs::read("foo.txt").await.unwrap(); - let to = fs::read("bar.txt").await.unwrap(); + let source_path = dir.path().join("foo.txt"); + let dest_path = dir.path().join("bar.txt"); + + fs::write(&source_path, b"Hello File!").await.unwrap(); + fs::copy(&source_path, &dest_path).await.unwrap(); + + let from = fs::read(&source_path).await.unwrap(); + let to = fs::read(&dest_path).await.unwrap(); assert_eq!(from, to); }