diff --git a/src/build/runtime.rs b/src/build/runtime.rs index 537e567..479cd80 100644 --- a/src/build/runtime.rs +++ b/src/build/runtime.rs @@ -54,7 +54,7 @@ mod tests { use super::*; - use crate::utils::replicate_android_project_to_temp; + use crate::utils::{clean_temp, replicate_android_project_to_temp}; #[test] fn test_build_runtime() { @@ -71,7 +71,7 @@ mod tests { AndroidBuildRuntime::KTS ); - let _ = std::fs::remove_dir_all(groovy_project_path); - let _ = std::fs::remove_dir_all(kotlin_project_path); + clean_temp(groovy_project_path); + clean_temp(kotlin_project_path); } } diff --git a/src/github/deploy.rs b/src/github/deploy.rs index a1442ab..7eb58b2 100644 --- a/src/github/deploy.rs +++ b/src/github/deploy.rs @@ -45,7 +45,7 @@ mod test { use super::*; use crate::{ build::runtime::AndroidBuildRuntime, github::create_github_dotfiles_dir, - utils::replicate_android_project_to_temp, + utils::{clean_temp, replicate_android_project_to_temp}, }; #[test] @@ -72,6 +72,6 @@ mod test { assert_eq!(path.exists(), true); } - let _ = std::fs::remove_dir_all(kotlin_project_path); + clean_temp(kotlin_project_path); } } diff --git a/src/github/mod.rs b/src/github/mod.rs index b0b1afc..b7161c4 100644 --- a/src/github/mod.rs +++ b/src/github/mod.rs @@ -22,7 +22,7 @@ pub fn create_github_dotfiles_dir(project_path: &Path) { #[cfg(test)] mod test { - use crate::{build::runtime::AndroidBuildRuntime, utils::replicate_android_project_to_temp}; + use crate::{build::runtime::AndroidBuildRuntime, utils::{clean_temp, replicate_android_project_to_temp}}; use super::*; @@ -32,7 +32,7 @@ mod test { assert_eq!(exists_github_dotfiles_dir(&kotlin_project_path), false); - let _ = std::fs::remove_dir_all(kotlin_project_path); + clean_temp(kotlin_project_path); } #[test] @@ -44,6 +44,6 @@ mod test { assert_eq!(kotlin_project_path.join(".github").exists(), true); - let _ = fs::remove_dir_all(kotlin_project_path); + clean_temp(kotlin_project_path); } } diff --git a/src/source/module.rs b/src/source/module.rs index f9c9c40..9cded79 100644 --- a/src/source/module.rs +++ b/src/source/module.rs @@ -102,7 +102,8 @@ pub mod build_src { mod test { use crate::{ - build::runtime::AndroidBuildRuntime, utils::replicate_android_project_to_temp, + build::runtime::AndroidBuildRuntime, + utils::{clean_temp, replicate_android_project_to_temp}, }; use super::*; @@ -119,7 +120,7 @@ pub mod build_src { assert_eq!(build_src_kotlin_path.exists(), true); - let _ = std::fs::remove_dir_all(kotlin_project_path); + clean_temp(kotlin_project_path); } #[test] @@ -146,7 +147,7 @@ pub mod build_src { assert_eq!(kotlin_files_present, true); - let _ = std::fs::remove_dir_all(kotlin_project_path); + clean_temp(kotlin_project_path); } } } diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 1257630..88fc02b 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -83,3 +83,8 @@ pub fn replicate_android_project_to_temp(build_runtime: AndroidBuildRuntime) -> android_project_temp_dir } + +pub fn clean_temp(android_project_path: PathBuf) { + fs::remove_dir_all(android_project_path.parent().unwrap()) + .expect("Error clean project dir from temp directory"); +}