#directory #temp-dir #temporary-files #temp #test-files #test

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

#445 in Testing

Download history 164/week @ 2024-11-17 263/week @ 2024-11-24 317/week @ 2024-12-01 706/week @ 2024-12-08 1110/week @ 2024-12-15 249/week @ 2024-12-22 207/week @ 2024-12-29 732/week @ 2025-01-05 1201/week @ 2025-01-12 1391/week @ 2025-01-19 559/week @ 2025-01-26 741/week @ 2025-02-02 863/week @ 2025-02-09 712/week @ 2025-02-16 1431/week @ 2025-02-23 565/week @ 2025-03-02

3,659 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

~330KB