paladin-ai 0.4.3

Enterprise AI orchestration framework with multi-agent coordination patterns
Documentation
//! Integration tests for CLI commands
//!
//! These tests verify end-to-end functionality of CLI commands with realistic
//! configurations and mocked external dependencies.

use paladin::application::cli::commands::features::FeatureCategory;
use std::env;
use tempfile::TempDir;

// ============ Test Fixtures ============

#[allow(dead_code)]
struct TestContext {
    _temp_dir: TempDir,
    original_env: Vec<(String, Option<String>)>,
}

impl TestContext {
    #[allow(dead_code)]
    fn new() -> Self {
        let temp_dir = tempfile::tempdir().expect("Failed to create temp dir");

        // Save original env vars
        let env_keys = ["OPENAI_API_KEY", "ANTHROPIC_API_KEY", "DEEPSEEK_API_KEY"];
        let original_env: Vec<_> = env_keys
            .iter()
            .map(|k| (k.to_string(), env::var(k).ok()))
            .collect();

        Self {
            _temp_dir: temp_dir,
            original_env,
        }
    }

    #[allow(dead_code)]
    fn set_mock_env_vars(&self) {
        #[allow(dead_code)]
        {
            unsafe {
                env::set_var("OPENAI_API_KEY", "sk-mock-openai-key-for-testing");
                env::set_var("ANTHROPIC_API_KEY", "sk-ant-mock-anthropic-key");
                env::set_var("DEEPSEEK_API_KEY", "sk-mock-deepseek-key");
            }
        }
    }
}

impl Drop for TestContext {
    fn drop(&mut self) {
        // Restore original env vars
        unsafe {
            for (key, value) in &self.original_env {
                match value {
                    Some(v) => env::set_var(key, v),
                    None => env::remove_var(key),
                }
            }
        }
    }
}

// ============ Basic Integration Tests ============

#[test]
fn test_features_command_all_categories() {
    // Test that all categories can be filtered
    for category in [
        FeatureCategory::Agent,
        FeatureCategory::Battalion,
        FeatureCategory::Orchestration,
        FeatureCategory::Memory,
        FeatureCategory::Utilities,
    ] {
        // Just verify the enum variants exist
        let _cat = category;
    }
}

#[test]
fn test_config_yaml_parsing() {
    let config_content = r#"
paladin:
  name: "test-paladin"
  model: "gpt-4"
  temperature: 0.7
"#;

    // Parse config
    let parsed: Result<serde_yaml::Value, _> = serde_yaml::from_str(config_content);
    assert!(parsed.is_ok());
}

#[test]
fn test_invalid_yaml_handling() {
    let invalid_yaml = "invalid: yaml: structure: [unclosed";
    let result: Result<serde_yaml::Value, _> = serde_yaml::from_str(invalid_yaml);
    assert!(result.is_err());
}