in focus/operations/src/selection.rs [833:895]
fn selection_save_new_file() -> 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_d".to_string(),
Some("project_d".to_string()),
Some("project d".to_string()),
fixture.app.clone(),
)?;
assert_eq!(
fs::read_to_string(
&fixture
.sparse_repo_path
.join("focus/projects/project_d.projects.json")
)?,
r#"{
"projects": [
{
"name": "team_zissou/project_d",
"description": "project d",
"targets": [
"bazel://project_a/...",
"bazel://project_b/..."
],
"projects": [
"team_banzai/project_a"
]
}
]
}"#
);
Ok(())
}