fn project_cache_generates_all_projects_internal()

in focus/operations/src/testing/sync_with_project_cache.rs [202:255]


fn project_cache_generates_all_projects_internal(location: Location) -> Result<()> {
    init_logging();

    let fixture = Fixture::new(location)?;
    let app = fixture.underlying.app.clone();
    if location == Location::Dense {
        // Also configure sparse since we will query there.
        fixture.configure_endpoint(Location::Sparse)?;
    }
    fixture.configure_endpoint(location)?;
    let repo_name = format!(
        "project_cache_generates_all_projects_internal_{:?}",
        location
    );
    fixture
        .configure_remote(&repo_name, Location::Dense)
        .context("Configuring dense repo")?;
    fixture
        .configure_remote(&repo_name, Location::Sparse)
        .context("Configuring sparse repo")?;

    fixture.generate_content(10)?;

    tracing::debug!(repo = ?fixture.repo_path());

    let selection_manager = fixture.underlying.sparse_repo()?.selection_manager()?;
    let project_names: Vec<String> = selection_manager
        .project_catalog()
        .optional_projects
        .underlying
        .iter()
        .map(|(name, _)| name.to_owned())
        .collect();
    assert!(!project_names.is_empty());

    crate::selection::add(
        &fixture.underlying.sparse_repo_path,
        true,
        project_names,
        false,
        app.clone(),
    )?;

    let result = crate::sync::run(
        &SyncRequest::new(
            &fixture.underlying.sparse_repo_path,
            crate::sync::SyncMode::RequireProjectCache,
        ),
        app,
    )?;
    assert_eq!(result.mechanism, SyncMechanism::ProjectCache);

    Ok(())
}