Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src-rust/crates/core/src/memdir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,16 @@ mod tests {

#[test]
fn hosted_memory_path_uses_separate_namespace() {
// Serialize against every COVEN_CODE_TEST_HOME mutator (cave-r78ad):
// path resolution reads the home through config_home(), so a parallel
// test's set_var/remove_var mid-test makes two resolutions disagree.
// Pin a private home for the duration so the assertions are hermetic.
let home = tempfile::tempdir().unwrap();
let _lock = crate::coven_shared::COVEN_HOME_ENV_LOCK
.lock()
.unwrap_or_else(|err| err.into_inner());
let original_test_home = std::env::var("COVEN_CODE_TEST_HOME").ok();
std::env::set_var("COVEN_CODE_TEST_HOME", home.path());
let project = PathBuf::from("/tmp/repo");
let scope = crate::hosted_review::HostedReviewScope::new(
"tenant-a".to_string(),
Expand All @@ -1061,10 +1071,25 @@ mod tests {
assert!(hosted.to_string_lossy().contains("install-1"));
assert!(hosted.to_string_lossy().contains("repo-1"));
assert!(hosted.to_string_lossy().contains("default-branch"));

match original_test_home {
Some(value) => std::env::set_var("COVEN_CODE_TEST_HOME", value),
None => std::env::remove_var("COVEN_CODE_TEST_HOME"),
}
Comment on lines +1075 to +1078
}

#[test]
fn hosted_memory_path_splits_installations_and_domains() {
// Serialize against every COVEN_CODE_TEST_HOME mutator (cave-r78ad):
// path resolution reads the home through config_home(), so a parallel
// test's set_var/remove_var mid-test makes two resolutions disagree.
// Pin a private home for the duration so the assertions are hermetic.
let home = tempfile::tempdir().unwrap();
let _lock = crate::coven_shared::COVEN_HOME_ENV_LOCK
.lock()
.unwrap_or_else(|err| err.into_inner());
let original_test_home = std::env::var("COVEN_CODE_TEST_HOME").ok();
std::env::set_var("COVEN_CODE_TEST_HOME", home.path());
let project = PathBuf::from("/tmp/repo");
let first_install = crate::hosted_review::HostedReviewScope::new(
"tenant-a".to_string(),
Expand Down Expand Up @@ -1110,6 +1135,11 @@ mod tests {
assert_ne!(first, second);
assert_ne!(first, branch);
assert!(branch.to_string_lossy().contains("branch-feature~2Freview"));

match original_test_home {
Some(value) => std::env::set_var("COVEN_CODE_TEST_HOME", value),
None => std::env::remove_var("COVEN_CODE_TEST_HOME"),
}
}

#[test]
Expand Down Expand Up @@ -1161,6 +1191,16 @@ mod tests {

#[test]
fn hosted_memory_ignores_local_checkout_path() {
// Serialize against every COVEN_CODE_TEST_HOME mutator (cave-r78ad):
// path resolution reads the home through config_home(), so a parallel
// test's set_var/remove_var mid-test makes two resolutions disagree.
// Pin a private home for the duration so the assertions are hermetic.
let home = tempfile::tempdir().unwrap();
let _lock = crate::coven_shared::COVEN_HOME_ENV_LOCK
.lock()
.unwrap_or_else(|err| err.into_inner());
let original_test_home = std::env::var("COVEN_CODE_TEST_HOME").ok();
std::env::set_var("COVEN_CODE_TEST_HOME", home.path());
let scope = crate::hosted_review::HostedReviewScope::new(
"tenant-a".to_string(),
"install-1".to_string(),
Expand Down Expand Up @@ -1197,6 +1237,11 @@ mod tests {
)
.unwrap();
assert_ne!(first, same_path_other_repo);

match original_test_home {
Some(value) => std::env::set_var("COVEN_CODE_TEST_HOME", value),
None => std::env::remove_var("COVEN_CODE_TEST_HOME"),
}
}

#[test]
Expand Down