#![cfg_attr(coverage_nightly, coverage(off))]
use super::config::CacheConfig;
use super::manager::SessionCacheManager;
use anyhow::Result;
pub type UnifiedCacheConfig = CacheConfig;
pub struct UnifiedCacheManager {
inner: SessionCacheManager,
}
impl UnifiedCacheManager {
pub fn new(config: UnifiedCacheConfig) -> Result<Self> {
Ok(Self {
inner: SessionCacheManager::new(config),
})
}
pub fn clear_all(&self) {
self.inner.clear_all();
}
}
pub type UnifiedCacheDiagnostics = super::diagnostics::CacheDiagnostics;
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod property_tests {
use proptest::prelude::*;
proptest! {
#[test]
fn basic_property_stability(_input in ".*") {
prop_assert!(true);
}
#[test]
fn module_consistency_check(_x in 0u32..1000) {
prop_assert!(_x < 1001);
}
}
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod coverage_tests {
use super::*;
#[test]
fn test_unified_cache_manager_new() {
let config = UnifiedCacheConfig::default();
let result = UnifiedCacheManager::new(config);
assert!(result.is_ok());
}
#[test]
fn test_unified_cache_manager_new_with_custom_config() {
let config = UnifiedCacheConfig {
max_memory_mb: 256,
enable_watch: false,
ast_ttl_secs: 600,
template_ttl_secs: 1200,
dag_ttl_secs: 300,
churn_ttl_secs: 3600,
git_stats_ttl_secs: 1800,
warmup_on_startup: true,
warmup_patterns: vec!["**/*.rs".to_string()],
git_cache_by_branch: false,
git_cache_max_age_days: 14,
parallel_warmup_threads: 8,
cache_compression: true,
eviction_batch_size: 20,
};
let result = UnifiedCacheManager::new(config);
assert!(result.is_ok());
}
#[test]
fn test_unified_cache_manager_clear_all() {
let config = UnifiedCacheConfig::default();
let manager = UnifiedCacheManager::new(config).unwrap();
manager.clear_all();
}
#[test]
fn test_unified_cache_manager_clear_all_multiple_times() {
let config = UnifiedCacheConfig::default();
let manager = UnifiedCacheManager::new(config).unwrap();
manager.clear_all();
manager.clear_all();
manager.clear_all();
}
#[test]
fn test_unified_cache_config_type_alias() {
let config: UnifiedCacheConfig = CacheConfig::default();
assert_eq!(config.max_memory_mb, 100);
assert!(config.enable_watch);
}
#[test]
fn test_unified_cache_diagnostics_type_alias() {
fn _assert_type_alias() -> Option<UnifiedCacheDiagnostics> {
None
}
}
#[test]
fn test_unified_cache_manager_with_minimal_config() {
let config = UnifiedCacheConfig {
max_memory_mb: 1,
enable_watch: false,
ast_ttl_secs: 1,
template_ttl_secs: 1,
dag_ttl_secs: 1,
churn_ttl_secs: 1,
git_stats_ttl_secs: 1,
warmup_on_startup: false,
warmup_patterns: vec![],
git_cache_by_branch: false,
git_cache_max_age_days: 1,
parallel_warmup_threads: 1,
cache_compression: false,
eviction_batch_size: 1,
};
let result = UnifiedCacheManager::new(config);
assert!(result.is_ok());
}
#[test]
fn test_unified_cache_manager_with_large_config() {
let config = UnifiedCacheConfig {
max_memory_mb: 4096,
enable_watch: true,
ast_ttl_secs: 86400,
template_ttl_secs: 86400,
dag_ttl_secs: 86400,
churn_ttl_secs: 86400,
git_stats_ttl_secs: 86400,
warmup_on_startup: true,
warmup_patterns: vec![
"**/*.rs".to_string(),
"**/*.py".to_string(),
"**/*.ts".to_string(),
"**/*.tsx".to_string(),
"**/*.js".to_string(),
"**/*.jsx".to_string(),
],
git_cache_by_branch: true,
git_cache_max_age_days: 30,
parallel_warmup_threads: 16,
cache_compression: true,
eviction_batch_size: 100,
};
let result = UnifiedCacheManager::new(config);
assert!(result.is_ok());
}
}