Sha256: ec78709cae9e6d5afd7422b06303a192946845e8f5f78465eac8b3b7ddb8480e

Contents?: true

Size: 788 Bytes

Versions: 3

Compression:

Stored size: 788 Bytes

Contents

#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations

use tempfile::tempdir;
use tokio::fs;

#[tokio::test]
async fn rename_file() {
    let temp_dir = tempdir().unwrap();

    let file_path = temp_dir.path().join("a.txt");

    fs::write(&file_path, b"Hello File!").await.unwrap();

    assert!(fs::try_exists(&file_path).await.unwrap());

    let new_file_path = temp_dir.path().join("b.txt");

    fs::rename(&file_path, &new_file_path).await.unwrap();

    assert!(fs::try_exists(new_file_path).await.unwrap());

    // original file should no longer exist
    match fs::try_exists(file_path).await {
        Ok(exists) => assert!(!exists),
        Err(_) => println!("ignored try_exists error after rename"),
    };
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wasmtime-9.0.1 ./ext/cargo-vendor/tokio-1.28.1/tests/fs_rename.rs
wasmtime-8.0.0 ./ext/cargo-vendor/tokio-1.27.0/tests/fs_rename.rs
wasmtime-7.0.0 ./ext/cargo-vendor/tokio-1.27.0/tests/fs_rename.rs