From 941c0aea7be967a54d692f67124d56097135b19b Mon Sep 17 00:00:00 2001 From: Diyahir <32445955+diyahir@users.noreply.github.com> Date: Thu, 5 Sep 2024 18:54:23 +0200 Subject: [PATCH] fixing unit tests --- test-utils/src/setup.rs | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/test-utils/src/setup.rs b/test-utils/src/setup.rs index 5ea87c90..3f2ecd4a 100644 --- a/test-utils/src/setup.rs +++ b/test-utils/src/setup.rs @@ -708,24 +708,19 @@ pub mod common { } pub fn get_absolute_path_from_relative(relative_path: &str) -> String { - let mut path = env::current_dir().unwrap(); - // println!("Current directory: {:?}", path); - let fluid_protocol_index = path - .to_str() - .unwrap() - .find("fluid-protocol/") - .unwrap_or_else(|| path.to_str().unwrap().len()); - - path.push("fluid-protocol/"); - // length of fluid procol - let len = "fluid-protocol/".len(); + let current_dir = env::current_dir().unwrap(); - let mut result = - path.to_str().unwrap().to_string()[..fluid_protocol_index + len].to_string(); + let fluid_protocol_path = current_dir + .ancestors() + .find(|p| p.ends_with("fluid-protocol")) + .unwrap_or(¤t_dir) + .to_path_buf(); - result.push_str(relative_path); - - result + fluid_protocol_path + .join(relative_path) + .to_str() + .unwrap() + .to_string() } pub async fn add_asset(