diff options
Diffstat (limited to 'tests/fixtures/mod.rs')
-rw-r--r-- | tests/fixtures/mod.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/fixtures/mod.rs b/tests/fixtures/mod.rs index 9cfd2cf..cec912a 100644 --- a/tests/fixtures/mod.rs +++ b/tests/fixtures/mod.rs @@ -4,13 +4,22 @@ use port_check::free_local_port; use rstest::fixture; /// Error type used by tests -pub type Error = Box<std::error::Error>; +pub type Error = Box<dyn std::error::Error>; /// File names for testing purpose #[allow(dead_code)] pub static FILES: &[&str] = &["test.txt", "test.html", "test.mkv"]; -/// Test fixture which creates a temporary directory with a few files inside. +/// Directory names for testing purpose +#[allow(dead_code)] +pub static DIRECTORIES: &[&str] = &["dira/", "dirb/", "dirc/"]; + +/// Name of a deeply nested file +#[allow(dead_code)] +pub static DEEPLY_NESTED_FILE: &str = "very/deeply/nested/test.rs"; + +/// Test fixture which creates a temporary directory with a few files and directories inside. +/// The directories also contain files. #[fixture] #[allow(dead_code)] pub fn tmpdir() -> TempDir { @@ -21,6 +30,18 @@ pub fn tmpdir() -> TempDir { .write_str("Test Hello Yes") .expect("Couldn't write to file"); } + for &directory in DIRECTORIES { + for &file in FILES { + tmpdir + .child(format!("{}{}", directory, file)) + .write_str(&format!("This is {}{}", directory, file)) + .expect("Couldn't write to file"); + } + } + tmpdir + .child(&DEEPLY_NESTED_FILE) + .write_str("File in a deeply nested directory.") + .expect("Couldn't write to file"); tmpdir } |