Avoid file system races in 'TempFile' doctests.

This changes 'TempFile' doctests so that different file names are used
across them, avoiding race conditions where one test deletes a file
another test just created and thus expects to subsequently exist.
This commit is contained in:
Sergio Benitez 2021-05-22 21:00:09 -07:00
parent 59851a621c
commit 2d70027a1b
1 changed files with 3 additions and 3 deletions

View File

@ -153,7 +153,7 @@ impl<'v> TempFile<'v> {
/// #[post("/", data = "<file>")]
/// async fn handle(mut file: TempFile<'_>) -> std::io::Result<()> {
/// # assert!(file.path().is_none());
/// # let some_path = std::env::temp_dir().join("some-file.txt");
/// # let some_path = std::env::temp_dir().join("some-persist.txt");
/// file.persist_to(&some_path).await?;
/// assert_eq!(file.path(), Some(&*some_path));
///
@ -291,7 +291,7 @@ impl<'v> TempFile<'v> {
/// #[post("/", data = "<file>")]
/// async fn handle(mut file: TempFile<'_>) -> std::io::Result<()> {
/// # assert!(file.path().is_none());
/// # let some_path = std::env::temp_dir().join("some-file.txt");
/// # let some_path = std::env::temp_dir().join("some-copy.txt");
/// file.move_copy_to(&some_path).await?;
/// # assert_eq!(file.path(), Some(&*some_path));
///
@ -348,7 +348,7 @@ impl<'v> TempFile<'v> {
/// #[post("/", data = "<file>")]
/// async fn handle(mut file: TempFile<'_>) -> std::io::Result<()> {
/// # assert!(file.path().is_none());
/// # let some_path = std::env::temp_dir().join("some-file.txt");
/// # let some_path = std::env::temp_dir().join("some-path.txt");
/// file.persist_to(&some_path).await?;
/// assert_eq!(file.path(), Some(&*some_path));
///