Struct test_files::TestFiles[][src]

pub struct TestFiles(_);

Implementations

Creates a plain file under temporary directory, with specified content.

Examples
use indoc::indoc;
use std::fs;

let temp_dir = test_files::TestFiles::new();
temp_dir.file("a/b/c.txt", indoc!{"
    ok
"})
.file("b/c/d.txt", indoc!{"
    fine
"});

let file_path = temp_dir.path().join("a").join("b").join("c.txt");
let written_content = fs::read_to_string(file_path).unwrap();
assert_eq!(written_content, "ok");

let file_path = temp_dir.path().join("b").join("c").join("d.txt");
let written_content = fs::read_to_string(file_path).unwrap();
assert_eq!(written_content, "fine");

Creates a new temporary directory that is removed when it goes out of scope.

Panics on failure

Examples
let temp_dir = test_files::TestFiles::new();

assert!(temp_dir.path().is_dir());

Returns the path of the underlying temporary directory.

Examples
let temp_dir = test_files::TestFiles::new();

assert!(temp_dir.path().is_dir());

Tries to create a plain file under temporary directory with specified content.

Examples
use indoc::indoc;
use std::fs;

let temp_dir = test_files::TestFiles::new();
temp_dir.try_file("a/b/c.txt", indoc!{"
    ok
"})?
.try_file("b/c/d.txt", indoc!{"
    fine
"})?;

let file_path = temp_dir.path().join("a").join("b").join("c.txt");
let written_content = fs::read_to_string(file_path).unwrap();
assert_eq!(written_content, "ok");

let file_path = temp_dir.path().join("b").join("c").join("d.txt");
let written_content = fs::read_to_string(file_path).unwrap();
assert_eq!(written_content, "fine");

Tries to create a new temporary directory that is removed when it goes out of scope.

Examples
let temp_dir = test_files::TestFiles::try_new();

assert!(temp_dir.is_ok());
assert!(temp_dir.unwrap().path().is_dir());

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.