in focus/operations/src/selection.rs [758:830]
fn selection_save_new() -> Result<()> {
let fixture = RepoPairFixture::new()?;
fixture.perform_clone()?;
let projects = vec![String::from("team_zissou/project_c")];
crate::selection::add(
&fixture.sparse_repo_path,
true,
projects,
true,
fixture.app.clone(),
)?;
let project_names: HashSet<String> = fixture
.sparse_repo()?
.selection_manager()?
.selection()?
.projects
.into_iter()
.map(|p| p.name)
.collect();
assert_eq!(
project_names,
HashSet::from(["team_banzai/project_a".to_string()])
);
crate::selection::add(
&fixture.sparse_repo_path,
true,
vec!["bazel://project_a/...".to_string()],
true,
fixture.app.clone(),
)?;
crate::selection::save(
&fixture.sparse_repo_path,
"team_zissou/project_c_2".to_string(),
Some("project_c".to_string()),
Some("project c2".to_string()),
fixture.app.clone(),
)?;
assert_eq!(
fs::read_to_string(
&fixture
.sparse_repo_path
.join("focus/projects/project_c.projects.json")
)?,
r#"{
"projects": [
{
"name": "team_zissou/project_c",
"description": "Stuff relating to project C",
"targets": [
"bazel://project_b/..."
],
"projects": [
"team_banzai/project_a"
]
},
{
"name": "team_zissou/project_c_2",
"description": "project c2",
"targets": [
"bazel://project_a/...",
"bazel://project_b/..."
],
"projects": [
"team_banzai/project_a"
]
}
]
}"#
);
Ok(())
}