use bssh::config::{Config, InteractiveConfigUpdate, InteractiveMode};
use tempfile::tempdir;
#[tokio::test]
async fn test_config_save_and_load() -> Result<(), Box<dyn std::error::Error>> {
let mut config = Config::default();
config.interactive.default_mode = InteractiveMode::Multiplex;
config.interactive.prompt_format = "test> ".to_string();
config.interactive.show_timestamps = true;
let temp_dir = tempdir()?;
let config_path = temp_dir.path().join("test_config.yaml");
config.save(&config_path).await?;
let loaded_config = Config::load(&config_path).await?;
assert!(matches!(
loaded_config.interactive.default_mode,
InteractiveMode::Multiplex
));
assert_eq!(loaded_config.interactive.prompt_format, "test> ");
assert!(loaded_config.interactive.show_timestamps);
println!("✅ Configuration save and load test passed!");
Ok(())
}
#[tokio::test]
async fn test_config_update_preferences() -> Result<(), Box<dyn std::error::Error>> {
let mut config = Config::default();
config.interactive.prompt_format = "original> ".to_string();
config.interactive.show_timestamps = true;
let temp_dir = tempdir()?;
let config_path = temp_dir.path().join("test_config.yaml");
config.save(&config_path).await?;
let updates = InteractiveConfigUpdate {
prompt_format: Some("updated> ".to_string()),
show_timestamps: Some(false),
..Default::default()
};
config.update_interactive_preferences(None, updates).await?;
assert_eq!(config.interactive.prompt_format, "updated> ");
assert!(!config.interactive.show_timestamps);
println!("✅ Configuration update test passed!");
Ok(())
}