use crate::brain::provider::factory::force_enable_section;
use crate::config::{Config, ProviderConfig};
#[test]
fn disabled_section_is_enabled() {
let mut cfg = Config::default();
cfg.providers.claude_cli = Some(ProviderConfig {
enabled: false,
..ProviderConfig::default()
});
assert!(force_enable_section(&mut cfg, "claude-cli"));
assert!(cfg.providers.claude_cli.as_ref().unwrap().enabled);
}
#[test]
fn absent_cli_section_is_synthesized() {
let mut cfg = Config::default();
cfg.providers.claude_cli = None;
cfg.providers.opencode_cli = None;
cfg.providers.codex_cli = None;
for id in ["claude-cli", "opencode-cli", "codex-cli"] {
assert!(force_enable_section(&mut cfg, id), "{id} must synthesize");
}
assert!(cfg.providers.claude_cli.as_ref().unwrap().enabled);
assert!(cfg.providers.opencode_cli.as_ref().unwrap().enabled);
assert!(cfg.providers.codex_cli.as_ref().unwrap().enabled);
}
#[test]
fn absent_keyed_section_stays_uncreatable() {
let mut cfg = Config::default();
cfg.providers.anthropic = None;
assert!(!force_enable_section(&mut cfg, "anthropic"));
assert!(cfg.providers.anthropic.is_none());
}
#[test]
fn disabled_keyed_section_is_enabled() {
let mut cfg = Config::default();
cfg.providers.zhipu = Some(ProviderConfig {
enabled: false,
api_key: Some("test-key".into()),
..ProviderConfig::default()
});
assert!(force_enable_section(&mut cfg, "zhipu"));
assert!(cfg.providers.zhipu.as_ref().unwrap().enabled);
assert_eq!(
cfg.providers.zhipu.as_ref().unwrap().api_key.as_deref(),
Some("test-key")
);
}
#[test]
fn unknown_and_custom_ids_are_untouched() {
let mut cfg = Config::default();
assert!(!force_enable_section(&mut cfg, "custom"));
assert!(!force_enable_section(&mut cfg, "no-such-provider"));
}