Sha256: c5397d389b2aefef31e2f4bc5f7e4b4a2c9c1e3109945de9f93dffc98bf0ae00

Contents?: true

Size: 796 Bytes

Versions: 30

Compression:

Stored size: 796 Bytes

Contents

#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "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

30 entries across 30 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/tokio-1.43.0/tests/fs_rename.rs
wasmtime-28.0.0 ./ext/cargo-vendor/tokio-1.43.0/tests/fs_rename.rs
wasmtime-27.0.0 ./ext/cargo-vendor/tokio-1.41.1/tests/fs_rename.rs
wasmtime-26.0.0 ./ext/cargo-vendor/tokio-1.41.0/tests/fs_rename.rs
wasmtime-25.0.2 ./ext/cargo-vendor/tokio-1.40.0/tests/fs_rename.rs
wasmtime-25.0.1 ./ext/cargo-vendor/tokio-1.39.3/tests/fs_rename.rs
wasmtime-25.0.0 ./ext/cargo-vendor/tokio-1.39.3/tests/fs_rename.rs
wasmtime-24.0.0 ./ext/cargo-vendor/tokio-1.39.3/tests/fs_rename.rs
wasmtime-23.0.2 ./ext/cargo-vendor/tokio-1.36.0/tests/fs_rename.rs
wasmtime-22.0.0 ./ext/cargo-vendor/tokio-1.36.0/tests/fs_rename.rs
wasmtime-21.0.1 ./ext/cargo-vendor/tokio-1.36.0/tests/fs_rename.rs
wasmtime-20.0.2 ./ext/cargo-vendor/tokio-1.36.0/tests/fs_rename.rs
wasmtime-20.0.0 ./ext/cargo-vendor/tokio-1.36.0/tests/fs_rename.rs
wasmtime-18.0.3 ./ext/cargo-vendor/tokio-1.36.0/tests/fs_rename.rs
wasmtime-17.0.1 ./ext/cargo-vendor/tokio-1.35.1/tests/fs_rename.rs
wasmtime-17.0.0 ./ext/cargo-vendor/tokio-1.35.1/tests/fs_rename.rs
wasmtime-16.0.0 ./ext/cargo-vendor/tokio-1.35.1/tests/fs_rename.rs
wasmtime-15.0.1 ./ext/cargo-vendor/tokio-1.35.1/tests/fs_rename.rs
wasmtime-15.0.0 ./ext/cargo-vendor/tokio-1.35.1/tests/fs_rename.rs
wasmtime-14.0.4 ./ext/cargo-vendor/tokio-1.33.0/tests/fs_rename.rs