use anyhow::Result;
use tokio::fs;
use crate::common::{ManifestBuilder, TestProject};
#[tokio::test]
async fn test_pattern_performance() -> Result<()> {
agpm_cli::test_utils::init_test_logging(None);
let project = TestProject::new().await?;
let test_repo = project.create_source_repo("test-repo").await?;
for i in 0..100 {
let content = format!("# Agent {}\n\nAgent {} description", i, i);
test_repo.add_resource("agents", &format!("agent{:03}", i), &content).await?;
}
test_repo.commit_all("Add 100 agents")?;
test_repo.tag_version("v1.0.0")?;
let repo_url = test_repo.bare_file_url(project.sources_path()).await?;
let manifest = ManifestBuilder::new()
.add_source("test-repo", &repo_url)
.add_agent_pattern("all-agents", "test-repo", "agents/*.md", "v1.0.0")
.build();
project.write_manifest(&manifest).await?;
let start = std::time::Instant::now();
let output = project.run_agpm(&["install"])?;
assert!(output.success);
let duration = start.elapsed();
println!("Pattern installation of 100 files completed in {:?}", duration);
let lockfile_content = fs::read_to_string(project.project_path().join("agpm.lock")).await?;
let agent_count = lockfile_content.matches("agent").count();
assert!(agent_count >= 100, "Not all agents were installed");
Ok(())
}