mirror of https://github.com/rwf2/Rocket.git
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:
parent
59851a621c
commit
2d70027a1b
|
@ -153,7 +153,7 @@ impl<'v> TempFile<'v> {
|
||||||
/// #[post("/", data = "<file>")]
|
/// #[post("/", data = "<file>")]
|
||||||
/// async fn handle(mut file: TempFile<'_>) -> std::io::Result<()> {
|
/// async fn handle(mut file: TempFile<'_>) -> std::io::Result<()> {
|
||||||
/// # assert!(file.path().is_none());
|
/// # 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?;
|
/// file.persist_to(&some_path).await?;
|
||||||
/// assert_eq!(file.path(), Some(&*some_path));
|
/// assert_eq!(file.path(), Some(&*some_path));
|
||||||
///
|
///
|
||||||
|
@ -291,7 +291,7 @@ impl<'v> TempFile<'v> {
|
||||||
/// #[post("/", data = "<file>")]
|
/// #[post("/", data = "<file>")]
|
||||||
/// async fn handle(mut file: TempFile<'_>) -> std::io::Result<()> {
|
/// async fn handle(mut file: TempFile<'_>) -> std::io::Result<()> {
|
||||||
/// # assert!(file.path().is_none());
|
/// # 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?;
|
/// file.move_copy_to(&some_path).await?;
|
||||||
/// # assert_eq!(file.path(), Some(&*some_path));
|
/// # assert_eq!(file.path(), Some(&*some_path));
|
||||||
///
|
///
|
||||||
|
@ -348,7 +348,7 @@ impl<'v> TempFile<'v> {
|
||||||
/// #[post("/", data = "<file>")]
|
/// #[post("/", data = "<file>")]
|
||||||
/// async fn handle(mut file: TempFile<'_>) -> std::io::Result<()> {
|
/// async fn handle(mut file: TempFile<'_>) -> std::io::Result<()> {
|
||||||
/// # assert!(file.path().is_none());
|
/// # 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?;
|
/// file.persist_to(&some_path).await?;
|
||||||
/// assert_eq!(file.path(), Some(&*some_path));
|
/// assert_eq!(file.path(), Some(&*some_path));
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue