random-dir

Crates.iorandom-dir
lib.rsrandom-dir
version0.2.4
created_at2024-12-08 12:51:47.417814+00
updated_at2024-12-08 19:08:45.271919+00
descriptionCreate directories and files with random contents in tests.
homepagehttps://github.com/igankevich/random-dir
repositoryhttps://github.com/igankevich/random-dir
max_upload_size
id1476265
size17,708
Ivan Gankevich (igankevich)

documentation

https://docs.rs/random-dir

README

random-dir

Crates.io Version Docs dependency status

Introduction

random-dir is a library that helps create directories with random contents. The intended usage is to generate random directory, feed this directory as an input to some function, and then compare the output of this function to the expected output.

This crate is particularly useful to test archiver crates like kpea.

Example

use random_dir::list_dir_all;
use random_dir::Dir;
use arbtest::arbtest;

fn test_pack_unpack_symmetry() {
    arbtest(|u| {
        let directory: Dir = u.arbitrary()?;
        // Pack the directory to a temporary archive file.
        // Unpack the temporary archive file to `/tmp/unpack-dir`.
        let files1 = list_dir_all(directory.path()).unwrap();
        let files2 = list_dir_all("/tmp/unpack-dir").unwrap();
        assert_eq!(files1, files2);
        Ok(())
    });
}
Commit count: 3

cargo fmt