use anyhow::Result;
use vtcode_config::OptimizationConfig;
use vtcode_core::tools::registry::ToolRegistry;
#[tokio::test]
async fn test_real_tool_registry_optimizations() -> Result<()> {
let workspace = std::env::temp_dir();
let mut registry = ToolRegistry::new(workspace).await;
let initial_optimizations = registry.has_optimizations_enabled();
let (cache_size, cache_cap) = registry.hot_cache_stats();
assert_eq!(cache_size, 0);
assert_eq!(cache_cap, 16);
assert!(
initial_optimizations,
"Memory pool should be enabled by default"
);
let mut opt_config = OptimizationConfig::default();
opt_config.tool_registry.use_optimized_registry = true;
opt_config.tool_registry.hot_cache_size = 32;
opt_config.memory_pool.enabled = true;
registry.configure_optimizations(opt_config);
assert!(registry.has_optimizations_enabled());
let (cache_size, cache_cap) = registry.hot_cache_stats();
assert_eq!(cache_size, 0); assert_eq!(cache_cap, 32);
let memory_pool = registry.memory_pool();
let test_string = memory_pool.get_string();
memory_pool.return_string(test_string);
println!("v Real ToolRegistry optimizations are working!");
Ok(())
}
#[tokio::test]
async fn test_tool_hot_cache_functionality() -> Result<()> {
let workspace = std::env::temp_dir();
let mut registry = ToolRegistry::new(workspace).await;
let mut opt_config = OptimizationConfig::default();
opt_config.tool_registry.use_optimized_registry = true;
registry.configure_optimizations(opt_config);
let tool1 = registry.get_tool("nonexistent_tool");
assert!(tool1.is_none());
let (cache_size, _) = registry.hot_cache_stats();
assert_eq!(cache_size, 0);
registry.clear_hot_cache();
println!("v Hot cache functionality is working!");
Ok(())
}
#[tokio::test]
async fn test_optimization_config_integration() -> Result<()> {
let workspace = std::env::temp_dir();
let registry = ToolRegistry::new(workspace).await;
let config = registry.optimization_config();
assert!(config.tool_registry.use_optimized_registry);
assert!(config.memory_pool.enabled);
println!("v Optimization config integration is working!");
Ok(())
}