{
    "sourceFile": "crates/ggen-cli/tests/e2e.rs",
    "activeCommit": 0,
    "commits": [
        {
            "activePatchIndex": 1,
            "patches": [
                {
                    "date": 1762978889197,
                    "content": "Index: \n===================================================================\n--- \n+++ \n"
                },
                {
                    "date": 1762979402416,
                    "content": "Index: \n===================================================================\n--- \n+++ \n@@ -6,12 +6,12 @@\n //! - Complete project generation workflow\n //!\n //! 80/20 Focus: Real-world user scenarios\n \n-use chicago_tdd_tools::prelude::*;\n use assert_cmd::Command;\n use assert_fs::prelude::*;\n use assert_fs::TempDir;\n+use chicago_tdd_tools::prelude::*;\n use predicates::prelude::*;\n use std::fs;\n \n // ============================================================================\n"
                }
            ],
            "date": 1762978889197,
            "name": "Commit-0",
            "content": "//! End-to-End Tests - Complete User Workflows\n//!\n//! Tests full execution paths from CLI invocation to final output:\n//! - Complete template generation workflow\n//! - Full marketplace search and install flow\n//! - Complete project generation workflow\n//!\n//! 80/20 Focus: Real-world user scenarios\n\nuse chicago_tdd_tools::prelude::*;\nuse assert_cmd::Command;\nuse assert_fs::prelude::*;\nuse assert_fs::TempDir;\nuse predicates::prelude::*;\nuse std::fs;\n\n// ============================================================================\n// E2E: Complete Template Generation Workflow\n// ============================================================================\n\ntest!(e2e_template_generate_complete, {\n    // Arrange\n    let temp = TempDir::new().unwrap();\n    let template_file = temp.child(\"microservice.yaml\");\n    let output_dir = temp.child(\"my-service\");\n\n    template_file\n        .write_str(\n            r#\"\nname: \"rust-microservice\"\ndescription: \"Production-ready Rust microservice\"\nversion: \"1.0.0\"\n\nvariables:\n  - name: service_name\n    required: true\n    description: \"Name of the microservice\"\n  - name: port\n    default: \"8080\"\n    description: \"HTTP port\"\n  - name: database\n    default: \"postgres\"\n    description: \"Database type\"\n\nnodes:\n  - name: \"{{service_name}}\"\n    type: directory\n    children:\n      - name: \"src\"\n        type: directory\n        children:\n          - name: \"main.rs\"\n            type: file\n            content: |\n              use axum::{Router, Server};\n              use std::net::SocketAddr;\n\n              #[tokio::main]\n              async fn main() {\n                  let app = Router::new();\n                  let addr = SocketAddr::from(([127, 0, 0, 1], {{port}}));\n\n                  println!(\"🚀 {{service_name}} listening on {}\", addr);\n                  Server::bind(&addr)\n                      .serve(app.into_make_service())\n                      .await\n                      .unwrap();\n              }\n          - name: \"lib.rs\"\n            type: file\n            content: |\n              pub mod routes;\n              pub mod models;\n      - name: \"Cargo.toml\"\n        type: file\n        content: |\n          [package]\n          name = \"{{service_name}}\"\n          version = \"0.1.0\"\n          edition = \"2021\"\n\n          [dependencies]\n          axum = \"0.7\"\n          tokio = { version = \"1\", features = [\"full\"] }\n      - name: \".env.example\"\n        type: file\n        content: |\n          DATABASE_URL={{database}}://localhost/{{service_name}}\n          PORT={{port}}\n      - name: \"README.md\"\n        type: file\n        content: |\n          # {{service_name}}\n\n          Production-ready Rust microservice.\n\n          ## Quick Start\n\n          ```bash\n          cargo run\n          ```\n\n          Server runs on port {{port}}.\n\"#,\n        )\n        .unwrap();\n\n    // Act\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\n            \"template\",\n            \"generate-tree\",\n            \"--template\",\n            template_file.path().to_str().unwrap(),\n            \"--output\",\n            output_dir.path().to_str().unwrap(),\n            \"--var\",\n            \"service_name=payment-api\",\n            \"--var\",\n            \"port=3000\",\n            \"--var\",\n            \"database=postgres\",\n        ])\n        .assert()\n        .success();\n\n    // Assert\n    let service_dir = output_dir.child(\"payment-api\");\n    service_dir.assert(predicate::path::exists());\n\n    let main_rs = service_dir.child(\"src/main.rs\");\n    main_rs.assert(predicate::path::exists());\n    main_rs.assert(predicate::str::contains(\"payment-api\"));\n    main_rs.assert(predicate::str::contains(\"3000\"));\n\n    let cargo_toml = service_dir.child(\"Cargo.toml\");\n    cargo_toml.assert(predicate::path::exists());\n    cargo_toml.assert(predicate::str::contains(\"payment-api\"));\n\n    let env_example = service_dir.child(\".env.example\");\n    env_example.assert(predicate::path::exists());\n    env_example.assert(predicate::str::contains(\"postgres\"));\n    env_example.assert(predicate::str::contains(\"3000\"));\n\n    let readme = service_dir.child(\"README.md\");\n    readme.assert(predicate::path::exists());\n    readme.assert(predicate::str::contains(\"payment-api\"));\n});\n\ntest!(e2e_template_with_nested_structure, {\n    // Arrange\n    let temp = TempDir::new().unwrap();\n    let template_file = temp.child(\"webapp.yaml\");\n    let output_dir = temp.child(\"webapp\");\n\n    template_file\n        .write_str(\n            r#\"\nname: \"web-application\"\nvariables:\n  - name: app_name\n    required: true\n\nnodes:\n  - name: \"{{app_name}}\"\n    type: directory\n    children:\n      - name: \"frontend\"\n        type: directory\n        children:\n          - name: \"src\"\n            type: directory\n            children:\n              - name: \"App.tsx\"\n                type: file\n                content: \"export const App = () => <div>{{app_name}}</div>;\"\n          - name: \"package.json\"\n            type: file\n            content: '{\"name\": \"{{app_name}}-frontend\"}'\n      - name: \"backend\"\n        type: directory\n        children:\n          - name: \"src\"\n            type: directory\n            children:\n              - name: \"main.rs\"\n                type: file\n                content: \"fn main() { println!(\\\"{{app_name}}\\\"); }\"\n          - name: \"Cargo.toml\"\n            type: file\n            content: '[package]\\nname = \"{{app_name}}-backend\"'\n      - name: \"docker-compose.yml\"\n        type: file\n        content: |\n          version: '3.8'\n          services:\n            frontend:\n              build: ./frontend\n            backend:\n              build: ./backend\n\"#,\n        )\n        .unwrap();\n\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\n            \"template\",\n            \"generate-tree\",\n            \"--template\",\n            template_file.path().to_str().unwrap(),\n            \"--output\",\n            output_dir.path().to_str().unwrap(),\n            \"--var\",\n            \"app_name=my-app\",\n        ])\n        .assert()\n        .success();\n\n    // Assert\n    let app_dir = output_dir.child(\"my-app\");\n    app_dir\n        .child(\"frontend/src/App.tsx\")\n        .assert(predicate::path::exists());\n    app_dir\n        .child(\"backend/src/main.rs\")\n        .assert(predicate::path::exists());\n    app_dir\n        .child(\"docker-compose.yml\")\n        .assert(predicate::path::exists());\n});\n\n// ============================================================================\n// E2E: Marketplace Search and Discovery\n// ============================================================================\n\ntest!(e2e_marketplace_search_complete, {\n    // Arrange & Act & Assert\n    let mut cmd = Command::cargo_bin(\"ggen\").unwrap();\n    cmd.args([\"market\", \"search\", \"rust\", \"--limit\", \"10\"])\n        .assert()\n        .success();\n});\n\ntest!(e2e_marketplace_search_with_filters, {\n    // Arrange & Act & Assert\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\n            \"market\",\n            \"search\",\n            \"microservice\",\n            \"--category\",\n            \"backend\",\n            \"--limit\",\n            \"5\",\n        ])\n        .assert()\n        .success();\n});\n\ntest!(e2e_marketplace_package_info, {\n    // Arrange & Act & Assert\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\"market\", \"info\", \"rust-cli-template\"])\n        .assert()\n        .success();\n});\n\ntest!(e2e_marketplace_list_installed, {\n    // Arrange & Act & Assert\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\"market\", \"list\"])\n        .assert()\n        .success();\n});\n\n// ============================================================================\n// E2E: Complete Project Generation Workflow\n// ============================================================================\n\ntest!(e2e_project_gen_complete, {\n    // Arrange\n    let temp = TempDir::new().unwrap();\n    let project_dir = temp.child(\"my-cli-tool\");\n\n    // Act\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\n            \"project\",\n            \"gen\",\n            \"--name\",\n            \"my-cli-tool\",\n            \"--template\",\n            \"rust-cli\",\n            \"--output\",\n            project_dir.path().to_str().unwrap(),\n            \"--description\",\n            \"A command-line tool\",\n        ])\n        .assert()\n        .success();\n\n    // Assert\n    project_dir.assert(predicate::path::exists());\n});\n\ntest!(e2e_project_with_git_init, {\n    // Arrange\n    let temp = TempDir::new().unwrap();\n    let project_dir = temp.child(\"git-project\");\n\n    // Act\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\n            \"project\",\n            \"gen\",\n            \"--name\",\n            \"git-project\",\n            \"--template\",\n            \"rust-lib\",\n            \"--output\",\n            project_dir.path().to_str().unwrap(),\n            \"--git\",\n        ])\n        .assert()\n        .success();\n\n    // Assert\n    if project_dir.path().exists() {\n        assert!(true);\n    }\n});\n\n// ============================================================================\n// E2E: Complete Lifecycle Workflow\n// ============================================================================\n\ntest!(e2e_lifecycle_complete_workflow, {\n    // Arrange\n    let temp = TempDir::new().unwrap();\n    let make_file = temp.child(\"make.toml\");\n\n    make_file\n        .write_str(\n            r#\"\n[project]\nname = \"production-service\"\nversion = \"1.0.0\"\n\n[[phases]]\nname = \"clean\"\ndescription = \"Clean build artifacts\"\ncommands = [\n    \"echo 'Cleaning...'\",\n    \"rm -rf target/\"\n]\n\n[[phases]]\nname = \"install\"\ndescription = \"Install dependencies\"\ndepends_on = [\"clean\"]\ncommands = [\n    \"echo 'Installing dependencies...'\"\n]\n\n[[phases]]\nname = \"build\"\ndescription = \"Build the project\"\ndepends_on = [\"install\"]\ncommands = [\n    \"echo 'Building project...'\",\n    \"cargo build --release\"\n]\n\n[[phases]]\nname = \"test\"\ndescription = \"Run tests\"\ndepends_on = [\"build\"]\ncommands = [\n    \"echo 'Running tests...'\",\n    \"cargo test\"\n]\n\n[[phases]]\nname = \"deploy\"\ndescription = \"Deploy to production\"\ndepends_on = [\"test\"]\ncommands = [\n    \"echo 'Deploying to production...'\"\n]\n\"#,\n        )\n        .unwrap();\n\n    // Act & Assert\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\n            \"lifecycle\",\n            \"run\",\n            \"deploy\",\n            \"--manifest\",\n            make_file.path().to_str().unwrap(),\n        ])\n        .assert()\n        .success();\n});\n\ntest!(e2e_lifecycle_list_phases, {\n    let temp = TempDir::new().unwrap();\n    let make_file = temp.child(\"make.toml\");\n\n    make_file\n        .write_str(\n            r#\"\n[project]\nname = \"test\"\n\n[[phases]]\nname = \"build\"\ncommands = [\"echo 'build'\"]\n\n[[phases]]\nname = \"test\"\ncommands = [\"echo 'test'\"]\n\"#,\n        )\n        .unwrap();\n\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\n            \"lifecycle\",\n            \"list\",\n            \"--manifest\",\n            make_file.path().to_str().unwrap(),\n        ])\n        .assert()\n        .success()\n        .stdout(predicate::str::contains(\"build\").or(predicate::str::contains(\"Phases\")));\n});\n\n// ============================================================================\n// E2E: Graph Operations Workflow\n// ============================================================================\n\ntest!(e2e_graph_import_and_query, {\n    // Arrange\n    let temp = TempDir::new().unwrap();\n    let graph_file = temp.child(\"project-graph.ttl\");\n\n    graph_file\n        .write_str(\n            r#\"\n@prefix ex: <http://example.org/> .\n@prefix dc: <http://purl.org/dc/elements/1.1/> .\n\nex:project1 a ex:Project ;\n    dc:title \"My Project\" ;\n    dc:description \"A test project\" ;\n    ex:version \"1.0.0\" ;\n    ex:language \"Rust\" .\n\nex:project2 a ex:Project ;\n    dc:title \"Another Project\" ;\n    dc:description \"Another test\" ;\n    ex:version \"2.0.0\" ;\n    ex:language \"Python\" .\n\"#,\n        )\n        .unwrap();\n\n    // Act & Assert\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\n            \"graph\",\n            \"import\",\n            graph_file.path().to_str().unwrap(),\n            \"--format\",\n            \"turtle\",\n        ])\n        .assert()\n        .success();\n\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\n            \"graph\",\n            \"query\",\n            \"SELECT ?title WHERE { ?s dc:title ?title }\",\n            \"--format\",\n            \"sparql\",\n        ])\n        .assert()\n        .success();\n});\n\n// ============================================================================\n// E2E: AI Integration Workflow\n// ============================================================================\n\n#[cfg(feature = \"live-llm-tests\")]\ntest!(e2e_ai_generate_template, {\n    // Arrange\n    let temp = TempDir::new().unwrap();\n    let output_file = temp.child(\"ai-template.yaml\");\n\n    // Act & Assert\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\n            \"ai\",\n            \"generate\",\n            \"--prompt\",\n            \"Create a Rust REST API template\",\n            \"--output\",\n            output_file.path().to_str().unwrap(),\n        ])\n        .assert()\n        .success();\n\n    output_file.assert(predicate::path::exists());\n});\n\n// ============================================================================\n// E2E: Multi-Step Real-World Scenarios\n// ============================================================================\n\ntest!(e2e_scenario_new_microservice_project, {\n    // Arrange\n    let temp = TempDir::new().unwrap();\n\n    // Act & Assert\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\"market\", \"search\", \"microservice\", \"--limit\", \"5\"])\n        .assert()\n        .success();\n\n    let project_dir = temp.child(\"payment-service\");\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\n            \"project\",\n            \"gen\",\n            \"--name\",\n            \"payment-service\",\n            \"--template\",\n            \"rust-microservice\",\n            \"--output\",\n            project_dir.path().to_str().unwrap(),\n        ])\n        .assert()\n        .success();\n\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\"doctor\"])\n        .assert()\n        .success();\n});\n\ntest!(e2e_scenario_template_development, {\n    // Arrange\n    let temp = TempDir::new().unwrap();\n    let template_file = temp.child(\"custom-template.yaml\");\n    let test_output = temp.child(\"test-output\");\n\n    template_file\n        .write_str(\n            r##\"\nname: \"custom-template\"\nvariables:\n  - name: project_name\n    required: true\nnodes:\n  - name: \"{{project_name}}\"\n    type: directory\n    children:\n      - name: \"README.md\"\n        type: file\n        content: \"# {{project_name}}\"\n\"##,\n        )\n        .unwrap();\n\n    // Act\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\n            \"template\",\n            \"generate-tree\",\n            \"--template\",\n            template_file.path().to_str().unwrap(),\n            \"--output\",\n            test_output.path().to_str().unwrap(),\n            \"--var\",\n            \"project_name=test-project\",\n        ])\n        .assert()\n        .success();\n\n    // Assert\n    test_output\n        .child(\"test-project/README.md\")\n        .assert(predicate::path::exists());\n});\n\n// ============================================================================\n// E2E: Error Recovery Scenarios\n// ============================================================================\n\ntest!(e2e_recovery_invalid_template_graceful, {\n    // Arrange\n    let temp = TempDir::new().unwrap();\n    let bad_template = temp.child(\"bad.yaml\");\n    bad_template.write_str(\"!!!invalid yaml!!!\").unwrap();\n\n    // Act & Assert\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\n            \"template\",\n            \"generate-tree\",\n            \"--template\",\n            bad_template.path().to_str().unwrap(),\n            \"--output\",\n            \"/tmp/output\",\n        ])\n        .assert()\n        .failure()\n        .stderr(predicate::str::is_empty().not());\n});\n\ntest!(e2e_recovery_network_timeout_graceful, {\n    // Arrange & Act & Assert\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\n            \"market\",\n            \"search\",\n            \"nonexistent-package-xyz-123\",\n            \"--limit\",\n            \"1\",\n        ])\n        .assert()\n        .success();\n});\n\n// ============================================================================\n// E2E: Performance Scenarios\n// ============================================================================\n\ntest!(e2e_performance_large_template, {\n    // Arrange\n    let temp = TempDir::new().unwrap();\n    let template_file = temp.child(\"large-template.yaml\");\n    let output_dir = temp.child(\"large-output\");\n\n    let mut nodes = String::from(\n        r#\"\nname: \"large-project\"\nvariables:\n  - name: project_name\n    required: true\nnodes:\n  - name: \"{{project_name}}\"\n    type: directory\n    children:\n\"#,\n    );\n\n    for i in 0..50 {\n        nodes.push_str(&format!(\n            r#\"\n      - name: \"file_{}.txt\"\n        type: file\n        content: \"Content for file {}\"\n\"#,\n            i, i\n        ));\n    }\n\n    template_file.write_str(&nodes).unwrap();\n\n    // Act & Assert\n    Command::cargo_bin(\"ggen\")\n        .unwrap()\n        .args([\n            \"template\",\n            \"generate-tree\",\n            \"--template\",\n            template_file.path().to_str().unwrap(),\n            \"--output\",\n            output_dir.path().to_str().unwrap(),\n            \"--var\",\n            \"project_name=large-project\",\n        ])\n        .assert()\n        .success();\n});\n"
        }
    ]
}