use std::sync::Arc;
use super::super::mock::{MockChatProvider, MockResolver};
use crate::core::sm::agent::SessionManagerAgent;
use crate::core::sm::config::SessionManagerConfig;
fn enabled_config() -> SessionManagerConfig {
SessionManagerConfig {
enabled: true,
..SessionManagerConfig::default()
}
}
fn agent_with(cfg: SessionManagerConfig, resolver: Arc<MockResolver>) -> SessionManagerAgent {
let data_root = std::env::temp_dir();
#[cfg(feature = "sm-memory")]
{
SessionManagerAgent::with_runtime(cfg, resolver, data_root, None)
}
#[cfg(not(feature = "sm-memory"))]
{
SessionManagerAgent::with_runtime(cfg, resolver, data_root)
}
}
#[tokio::test]
async fn health_no_runtime_is_degraded() {
let agent = SessionManagerAgent::new(enabled_config());
let health = agent.health().await;
assert!(!health.ok);
assert!(health.degraded);
assert_eq!(health.provider, "none");
}
#[tokio::test]
async fn health_degraded_resolver_is_degraded() {
let agent = agent_with(enabled_config(), Arc::new(MockResolver::degraded()));
let health = agent.health().await;
assert!(!health.ok);
assert!(health.degraded);
assert_eq!(health.provider, "none");
}
#[tokio::test]
async fn health_with_provider_is_ok() {
let provider = MockChatProvider::new("unused", 0.0);
let resolver = Arc::new(MockResolver::with_provider(provider));
let agent = agent_with(enabled_config(), resolver);
let health = agent.health().await;
assert!(health.ok);
assert!(!health.degraded);
assert_eq!(health.provider, "anthropic");
}
#[tokio::test]
async fn health_reports_model_tiers() {
let provider = MockChatProvider::new("unused", 0.0);
let resolver = Arc::new(MockResolver::with_provider(provider));
let agent = agent_with(enabled_config(), resolver);
let health = agent.health().await;
assert_eq!(
health.model_tiers.orchestration,
"anthropic/claude-sonnet-4-6"
);
assert_eq!(health.model_tiers.summary, "anthropic/claude-haiku");
assert_eq!(health.model_tiers.compaction, "anthropic/claude-haiku");
}