forked from tokio-rs/tokio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from tokio-rs/master
Add foo.txt and bar.txt to .gitignore (tokio-rs#2294)
- Loading branch information
Showing
1 changed file
with
10 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |