2 unstable releases

0.2.0 Apr 5, 2022
0.1.0 Oct 9, 2019

#334 in Testing

Download history 777/week @ 2024-06-19 1051/week @ 2024-06-26 607/week @ 2024-07-03 817/week @ 2024-07-10 667/week @ 2024-07-17 853/week @ 2024-07-24 742/week @ 2024-07-31 1151/week @ 2024-08-07 867/week @ 2024-08-14 577/week @ 2024-08-21 620/week @ 2024-08-28 814/week @ 2024-09-04 677/week @ 2024-09-11 459/week @ 2024-09-18 686/week @ 2024-09-25 515/week @ 2024-10-02

2,475 downloads per month
Used in 7 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

~310KB