#directory #temporary-files #file #file-path #test-files #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

#221 in Testing

Download history 414/week @ 2023-12-06 539/week @ 2023-12-13 421/week @ 2023-12-20 400/week @ 2023-12-27 382/week @ 2024-01-03 638/week @ 2024-01-10 561/week @ 2024-01-17 479/week @ 2024-01-24 301/week @ 2024-01-31 710/week @ 2024-02-07 485/week @ 2024-02-14 469/week @ 2024-02-21 500/week @ 2024-02-28 529/week @ 2024-03-06 477/week @ 2024-03-13 446/week @ 2024-03-20

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