#test #dir #file #directory #temp

dev test_dir

Easy creation of temporary file structure for test purpose

2 unstable releases

0.2.0 Apr 5, 2022
0.1.0 Oct 9, 2019

#200 in Testing

Download history 1080/week @ 2022-10-06 394/week @ 2022-10-13 754/week @ 2022-10-20 460/week @ 2022-10-27 482/week @ 2022-11-03 666/week @ 2022-11-10 600/week @ 2022-11-17 547/week @ 2022-11-24 434/week @ 2022-12-01 322/week @ 2022-12-08 432/week @ 2022-12-15 410/week @ 2022-12-22 579/week @ 2022-12-29 260/week @ 2023-01-05 319/week @ 2023-01-12 607/week @ 2023-01-19

1,822 downloads per month
Used in 4 crates

MIT license

14KB
285 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

~315KB