#test #dir #file #directory #temp

dev test_dir

Easy creation of temporary file structure for test purpose

1 unstable release

0.1.0 Oct 9, 2019

#10 in #temp

Download history 151/week @ 2021-08-08 439/week @ 2021-08-15 307/week @ 2021-08-22 199/week @ 2021-08-29 413/week @ 2021-09-05 675/week @ 2021-09-12 345/week @ 2021-09-19 308/week @ 2021-09-26 90/week @ 2021-10-03 121/week @ 2021-10-10 357/week @ 2021-10-17 463/week @ 2021-10-24 293/week @ 2021-10-31 179/week @ 2021-11-07 257/week @ 2021-11-14 254/week @ 2021-11-21

1,096 downloads per month
Used in 4 crates

MIT license

14KB
286 lines

TestDir

Fast creation of file structure for testing purpose.

Getting Started

Add the following dependency to Cargo manifest:

[dependencies]
test_dir = "0.1.0"

Example

use test_dir::{TestDir,FileType,DirBuilder};

{
  let temp = TestDir::temp()
      .create("test/dir", FileType::Dir)
      .create("test/file", FileType::EmptyFile)
      .create("test/random_file", FileType::RandomFile(100))
      .create("otherdir/zero_file", FileType::ZeroFile(100));

  let path: PathBuf = temp.path("test/random_file");
  assert!(path.exists());
}

// temp out-of-scope -> temp dir deleted

License

Licensed under MIT license, (LICENSE)


lib.rs:

test_dir

TestDir is a temporary directory builder. The target is to define a file structure for test purpose. It is not recommended to use in non-test environment.

use std::path::PathBuf;
use test_dir::{TestDir,FileType,DirBuilder};

let temp = TestDir::temp()
    .create("test/dir", FileType::Dir)
    .create("test/file", FileType::EmptyFile)
    .create("test/random_file", FileType::RandomFile(100))
    .create("otherdir/zero_file", FileType::ZeroFile(100));

let path: PathBuf = temp.path("test/random_file");
assert!(path.exists());

Dependencies

~360KB

Y]