2 unstable releases

0.2.0 Apr 5, 2022
0.1.0 Oct 9, 2019

#335 in Testing

Download history 891/week @ 2024-07-22 674/week @ 2024-07-29 1064/week @ 2024-08-05 1008/week @ 2024-08-12 548/week @ 2024-08-19 725/week @ 2024-08-26 715/week @ 2024-09-02 713/week @ 2024-09-09 503/week @ 2024-09-16 576/week @ 2024-09-23 715/week @ 2024-09-30 375/week @ 2024-10-07 441/week @ 2024-10-14 459/week @ 2024-10-21 351/week @ 2024-10-28 244/week @ 2024-11-04

1,506 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