lernie 0.1.39

lernie: the operator seat — the window and wire client for a yog server
Documentation
//! The scaffolding's own guarantees, since everything else leans on them.

use super::Scratch;

/// Two scratch directories are two directories, and each disappears with the
/// value that made it.
#[test]
fn a_scratch_is_unique_and_is_removed_when_it_drops() {
    let first = Scratch::new();
    let second = Scratch::new();
    assert_ne!(first.path(), second.path());
    assert!(first.path().is_dir());
    let path = first.join("inside");
    std::fs::write(&path, b"something").expect("write");
    let held = first.path().to_path_buf();
    drop(first);
    assert!(!held.exists(), "the scratch outlived its value");
    assert!(second.path().is_dir(), "and took nothing else with it");
}

/// `join` names and `dir` makes: the two spellings differ in exactly that, and
/// a test that wants a directory to exist says so.
#[test]
fn join_names_a_path_and_dir_makes_one() {
    let scratch = Scratch::new();
    assert!(!scratch.join("absent").exists());
    let made = scratch.dir("present");
    assert!(made.is_dir());
    assert_eq!(made, scratch.join("present"));
}