From f1b5b0915b40beca9c34a38f7799fb795682fa0f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 20 Oct 2019 13:11:44 +0200 Subject: [PATCH] Refactor file_path and provide helper function for store path Signed-off-by: Matthias Beyer --- tests/ui/src/imag.rs | 9 +++++++++ tests/ui/src/imag_create.rs | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/ui/src/imag.rs b/tests/ui/src/imag.rs index 3c517ce2..34edbb4c 100644 --- a/tests/ui/src/imag.rs +++ b/tests/ui/src/imag.rs @@ -55,7 +55,16 @@ pub fn stdout_of_command(mut command: Command) -> Vec { /// Create a PathBuf for a file in a TempDir pub fn file_path(tempdir: &TempDir, path_elements: &[&str]) -> PathBuf { + create_path_for(tempdir.path().to_path_buf(), path_elements) +} + +pub fn store_path(tempdir: &TempDir, path_elements: &[&str]) -> PathBuf { let mut path = tempdir.path().to_path_buf(); + path.push("store"); + create_path_for(path, path_elements) +} + +fn create_path_for(mut path: PathBuf, path_elements: &[&str]) -> PathBuf { path_elements.iter().for_each(|el| path.push(el)); debug!("Calculated path = {:?}", path); path diff --git a/tests/ui/src/imag_create.rs b/tests/ui/src/imag_create.rs index a857ed28..993ba366 100644 --- a/tests/ui/src/imag_create.rs +++ b/tests/ui/src/imag_create.rs @@ -50,7 +50,7 @@ fn test_creating_works() { call(&imag_home, &["test"]); - let entry_path = crate::imag::file_path(&imag_home, &["store", "test"]); + let entry_path = crate::imag::store_path(&imag_home, &["test"]); assert!(entry_path.exists(), "Entry was not created: {:?}", entry_path); assert!(entry_path.is_file() , "Entry is not a file: {:?}", entry_path);