ggen-cli-lib 26.7.3

CLI interface for ggen
Documentation
#![allow(
    clippy::unwrap_used,
    clippy::expect_used,
    clippy::panic,
    clippy::needless_raw_string_hashes,
    clippy::duration_suboptimal_units,
    clippy::branches_sharing_code,
    clippy::used_underscore_binding,
    clippy::single_char_pattern,
    clippy::ignore_without_reason,
    clippy::cloned_ref_to_slice_refs,
    clippy::doc_overindented_list_items,
    clippy::match_wildcard_for_single_variants,
    clippy::ignored_unit_patterns,
    clippy::needless_collect,
    clippy::unnecessary_map_or,
    clippy::manual_flatten,
    clippy::manual_strip,
    clippy::future_not_send,
    clippy::unnested_or_patterns,
    clippy::no_effect_underscore_binding,
    clippy::literal_string_with_formatting_args
)]
//! End-to-end integration tests for complete pack workflows
//!
//! Tests cover:
//! - Full installation workflow (download -> extract -> verify -> install)
//! - Multi-pack installation with dependencies
//! - Failure recovery and rollback
//! - SPARQL query execution on installed packs

// Mock types for integration testing
struct PackRegistry;
struct PackInstaller;
struct PackVerifier;

impl PackRegistry {
    fn new() -> Self {
        Self
    }

    fn search(&self, _query: &str) -> Vec<String> {
        vec!["pack1".to_string(), "pack2".to_string()]
    }

    fn get_pack(&self, _id: &str) -> Option<PackMetadata> {
        Some(PackMetadata {
            id: "test-pack".to_string(),
            version: "1.0.0".to_string(),
            dependencies: vec![],
        })
    }
}

impl PackInstaller {
    fn new() -> Self {
        Self
    }

    fn install(&self, _pack_id: &str) -> Result<(), String> {
        Ok(())
    }

    fn install_with_dependencies(&self, _pack_id: &str) -> Result<Vec<String>, String> {
        Ok(vec!["pack1".to_string(), "dep1".to_string()])
    }
}

impl PackVerifier {
    fn new() -> Self {
        Self
    }

    fn verify(&self, _pack_id: &str) -> Result<(), String> {
        Ok(())
    }
}

#[derive(Clone)]
struct PackMetadata {
    id: String,
    version: String,
    dependencies: Vec<String>,
}

// ============================================================================
// INTEGRATION TESTS - Complete Workflows
// ============================================================================

#[test]
fn test_complete_installation_workflow() {
    let registry = PackRegistry::new();
    let installer = PackInstaller::new();
    let verifier = PackVerifier::new();

    // 1. Search for pack
    let results = registry.search("test");
    assert!(!results.is_empty());

    // 2. Get pack metadata
    let pack = registry.get_pack("pack1").unwrap();
    assert_eq!(pack.id, "test-pack");

    // 3. Install pack
    let install_result = installer.install(&pack.id);
    assert!(install_result.is_ok());

    // 4. Verify installation
    let verify_result = verifier.verify(&pack.id);
    assert!(verify_result.is_ok());
}

#[test]
fn test_multi_pack_installation_with_dependencies() {
    let installer = PackInstaller::new();

    // Install pack with dependencies
    let result = installer.install_with_dependencies("main-pack");
    assert!(result.is_ok());

    let installed = result.unwrap();
    assert!(installed.len() >= 2); // Main pack + at least one dependency
}

#[test]
fn test_installation_failure_recovery() {
    // Test that failed installations don't leave partial state
    let registry = PackRegistry::new();
    let pack_id = "nonexistent-pack";

    let results = registry.search(pack_id);
    assert!(!results.contains(&pack_id.to_string()));
}

// ============================================================================
// FMEA INTEGRATION TESTS
// ============================================================================

#[test]
fn test_fmea_complete_installation_pipeline() {
    // FMEA: End-to-end installation success (RPN coverage)
    let registry = PackRegistry::new();
    let installer = PackInstaller::new();
    let verifier = PackVerifier::new();

    // Complete pipeline
    let pack = registry.get_pack("test-pack").unwrap();
    assert_eq!(pack.id, "test-pack");

    installer.install(&pack.id).unwrap();
    verifier.verify(&pack.id).unwrap();

    // Verify search results are consistent after pipeline
    let search_results = registry.search("test");
    assert!(search_results.contains(&"pack1".to_string()));
}