From 2c2076bd7794af15aa67a661153d5db1bc03eb1a Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Fri, 5 May 2023 17:49:46 -0700 Subject: [PATCH] Adjust tests to not create repositories inside repositories --- .../src/tests/randomized_integration_tests.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/collab/src/tests/randomized_integration_tests.rs b/crates/collab/src/tests/randomized_integration_tests.rs index c90354f214..c535bc8dce 100644 --- a/crates/collab/src/tests/randomized_integration_tests.rs +++ b/crates/collab/src/tests/randomized_integration_tests.rs @@ -29,7 +29,7 @@ use std::{ sync::{ atomic::{AtomicBool, Ordering::SeqCst}, Arc, - }, + }, ffi::OsStr, }; use util::ResultExt; @@ -765,7 +765,7 @@ async fn apply_client_operation( contents, } => { if !client.fs.directories().contains(&repo_path) { - return Err(TestError::Inapplicable); + client.fs.create_dir(&repo_path).await?; } log::info!( @@ -791,7 +791,7 @@ async fn apply_client_operation( new_branch, } => { if !client.fs.directories().contains(&repo_path) { - return Err(TestError::Inapplicable); + client.fs.create_dir(&repo_path).await?; } log::info!( @@ -1704,6 +1704,12 @@ impl TestPlan { .unwrap() .clone(); + let repo_path = if repo_path.file_name() == Some(&OsStr::new(".git")) { + repo_path.parent().unwrap().join(Alphanumeric.sample_string(&mut self.rng, 16)) + } else { + repo_path + }; + let mut file_paths = client .fs .files() @@ -1739,6 +1745,12 @@ impl TestPlan { .unwrap() .clone(); + let repo_path = if repo_path.file_name() == Some(&OsStr::new(".git")) { + repo_path.parent().unwrap().join(Alphanumeric.sample_string(&mut self.rng, 16)) + } else { + repo_path + }; + let new_branch = (self.rng.gen_range(0..10) > 3) .then(|| Alphanumeric.sample_string(&mut self.rng, 8));