File: directory_test.rs

package info (click to toggle)
rust-fsio 0.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 208 kB
  • sloc: makefile: 2
file content (33 lines) | stat: -rw-r--r-- 946 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use fsio::{directory, file};
use std::path::Path;

#[test]
fn create_test() {
    let result = directory::create("./target/__test/directory_test/dir1/dir2");
    assert!(result.is_ok());

    let path = Path::new("./target/__test/directory_test/dir1/dir2");
    assert!(path.exists());
}

#[test]
fn create_parent_test() {
    let result = directory::create_parent("./target/__test/directory_test/dir1/files/file.txt");
    assert!(result.is_ok());

    let path = Path::new("./target/__test/directory_test/dir1/files");
    assert!(path.exists());
}

#[test]
fn delete_test() {
    file::ensure_exists("./target/__test/directory_test/delete_directory/dir1/dir2/file.txt")
        .unwrap();
    let path = Path::new("./target/__test/directory_test/delete_directory");
    assert!(path.exists());

    let result = directory::delete("./target/__test/directory_test/delete_directory");
    assert!(result.is_ok());

    assert!(!path.exists());
}