refactor(fs/tests): group into modules

This commit is contained in:
Paul Campbell 2024-04-28 15:01:29 +01:00
parent a9057a8831
commit b32c10f080

View file

@ -4,6 +4,8 @@ use crate::fs;
type TestResult = Result<(), fs::Error>;
mod path_of {
use super::*;
#[test]
fn path_of_validate_fails_path_traversal() -> TestResult {
let fs = fs::temp()?;
@ -13,7 +15,10 @@ fn path_of_validate_fails_path_traversal() -> TestResult {
Ok(())
}
}
mod file {
use super::*;
#[test]
fn write_read_file_exists() -> TestResult {
let fs = fs::temp()?;
@ -34,9 +39,12 @@ fn write_read_file_exists() -> TestResult {
Ok(())
}
}
mod dir_create {
use super::*;
#[test]
fn create_dir_should_create_a_dir() -> TestResult {
fn dir_create_should_create_a_dir() -> TestResult {
let fs = fs::temp()?;
let pathbuf = fs.base().join("subdir");
@ -52,7 +60,7 @@ fn create_dir_should_create_a_dir() -> TestResult {
}
#[test]
fn create_dir_all_should_create_a_dir() -> TestResult {
fn dir_create_all_should_create_a_dir() -> TestResult {
let fs = fs::temp()?;
let pathbuf = fs.base().join("subdir").join("child");
@ -66,3 +74,4 @@ fn create_dir_all_should_create_a_dir() -> TestResult {
Ok(())
}
}