2 unstable releases

0.2.0 Apr 5, 2022
0.1.0 Oct 9, 2019

#227 in Testing

Download history 392/week @ 2024-01-01 549/week @ 2024-01-08 651/week @ 2024-01-15 471/week @ 2024-01-22 359/week @ 2024-01-29 616/week @ 2024-02-05 480/week @ 2024-02-12 481/week @ 2024-02-19 501/week @ 2024-02-26 491/week @ 2024-03-04 515/week @ 2024-03-11 545/week @ 2024-03-18 704/week @ 2024-03-25 531/week @ 2024-04-01 567/week @ 2024-04-08 596/week @ 2024-04-15

2,462 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

~315KB