{
    "sourceFile": "examples/advanced-rust-project/tests/test_rust_service.rs",
    "activeCommit": 0,
    "commits": [
        {
            "activePatchIndex": 0,
            "patches": [
                {
                    "date": 1760245074731,
                    "content": "Index: \n===================================================================\n--- \n+++ \n"
                }
            ],
            "date": 1760245074731,
            "name": "Commit-0",
            "content": "//! Tests for generated Rust service\n//! \n//! These tests validate the generated Rust service template\n//! and ensure it works correctly with the RDF domain model.\n\nuse std::collections::HashMap;\nuse serde_json::json;\n\n#[tokio::test]\nasync fn test_rust_service_generation() {\n    // Test that the Rust service template generates valid code\n    let template_content = include_str!(\"../../templates/rust-service.tmpl\");\n    \n    // Basic template validation\n    assert!(template_content.contains(\"{{ name | title }}\"));\n    assert!(template_content.contains(\"{{ name | snake }}\"));\n    assert!(template_content.contains(\"{{ name | pascal }}\"));\n    assert!(template_content.contains(\"sparql_results\"));\n    \n    // Validate frontmatter structure\n    assert!(template_content.starts_with(\"---\"));\n    assert!(template_content.contains(\"to:\"));\n    assert!(template_content.contains(\"vars:\"));\n    assert!(template_content.contains(\"prefixes:\"));\n    assert!(template_content.contains(\"sparql:\"));\n}\n\n#[tokio::test]\nasync fn test_api_endpoint_generation() {\n    // Test that the API endpoint template generates valid code\n    let template_content = include_str!(\"../../templates/api-endpoint.tmpl\");\n    \n    // Basic template validation\n    assert!(template_content.contains(\"{{ name | title }}\"));\n    assert!(template_content.contains(\"{{ method }}\"));\n    assert!(template_content.contains(\"{{ path }}\"));\n    assert!(template_content.contains(\"sparql_results\"));\n    \n    // Validate frontmatter structure\n    assert!(template_content.starts_with(\"---\"));\n    assert!(template_content.contains(\"to:\"));\n    assert!(template_content.contains(\"vars:\"));\n    assert!(template_content.contains(\"prefixes:\"));\n    assert!(template_content.contains(\"sparql:\"));\n}\n\n#[tokio::test]\nasync fn test_database_schema_generation() {\n    // Test that the database schema template generates valid code\n    let template_content = include_str!(\"../../templates/database-schema.tmpl\");\n    \n    // Basic template validation\n    assert!(template_content.contains(\"{{ name | title }}\"));\n    assert!(template_content.contains(\"{{ database }}\"));\n    assert!(template_content.contains(\"{{ orm }}\"));\n    assert!(template_content.contains(\"sparql_results\"));\n    \n    // Validate frontmatter structure\n    assert!(template_content.starts_with(\"---\"));\n    assert!(template_content.contains(\"to:\"));\n    assert!(template_content.contains(\"vars:\"));\n    assert!(template_content.contains(\"prefixes:\"));\n    assert!(template_content.contains(\"sparql:\"));\n}\n\n#[tokio::test]\nasync fn test_documentation_generation() {\n    // Test that the documentation template generates valid code\n    let template_content = include_str!(\"../../templates/documentation.tmpl\");\n    \n    // Basic template validation\n    assert!(template_content.contains(\"{{ name | title }}\"));\n    assert!(template_content.contains(\"{{ format }}\"));\n    assert!(template_content.contains(\"{{ style }}\"));\n    assert!(template_content.contains(\"sparql_results\"));\n    \n    // Validate frontmatter structure\n    assert!(template_content.starts_with(\"---\"));\n    assert!(template_content.contains(\"to:\"));\n    assert!(template_content.contains(\"vars:\"));\n    assert!(template_content.contains(\"prefixes:\"));\n    assert!(template_content.contains(\"sparql:\"));\n}\n\n#[tokio::test]\nasync fn test_rdf_domain_model() {\n    // Test that the RDF domain model is valid\n    let domain_content = include_str!(\"../../data/domain.ttl\");\n    \n    // Basic RDF validation\n    assert!(domain_content.contains(\"@prefix ex:\"));\n    assert!(domain_content.contains(\"ex:User a ex:Entity\"));\n    assert!(domain_content.contains(\"ex:Product a ex:Entity\"));\n    assert!(domain_content.contains(\"ex:Order a ex:Entity\"));\n    assert!(domain_content.contains(\"ex:Category a ex:Entity\"));\n    \n    // Validate API endpoints\n    assert!(domain_content.contains(\"ex:UserAPI a ex:APIEndpoint\"));\n    assert!(domain_content.contains(\"ex:ProductAPI a ex:APIEndpoint\"));\n    assert!(domain_content.contains(\"ex:OrderAPI a ex:APIEndpoint\"));\n    \n    // Validate database schema\n    assert!(domain_content.contains(\"ex:UsersTable a ex:Table\"));\n    assert!(domain_content.contains(\"ex:ProductsTable a ex:Table\"));\n    assert!(domain_content.contains(\"ex:OrdersTable a ex:Table\"));\n    assert!(domain_content.contains(\"ex:CategoriesTable a ex:Table\"));\n}\n\n#[tokio::test]\nasync fn test_sparql_queries() {\n    // Test that SPARQL queries are valid\n    let domain_content = include_str!(\"../../data/domain.ttl\");\n    \n    // Extract and validate SPARQL queries from templates\n    let templates = [\n        include_str!(\"../../templates/rust-service.tmpl\"),\n        include_str!(\"../../templates/api-endpoint.tmpl\"),\n        include_str!(\"../../templates/database-schema.tmpl\"),\n        include_str!(\"../../templates/documentation.tmpl\"),\n    ];\n    \n    for template in templates {\n        // Check for SPARQL query definitions\n        assert!(template.contains(\"sparql:\"));\n        assert!(template.contains(\"SELECT\"));\n        assert!(template.contains(\"WHERE\"));\n    }\n}\n\n#[tokio::test]\nasync fn test_template_filters() {\n    // Test that template filters work correctly\n    let test_cases = [\n        (\"hello_world\", \"camel\", \"helloWorld\"),\n        (\"hello_world\", \"pascal\", \"HelloWorld\"),\n        (\"hello_world\", \"snake\", \"hello_world\"),\n        (\"hello_world\", \"kebab\", \"hello-world\"),\n        (\"hello_world\", \"title\", \"Hello World\"),\n        (\"hello_world\", \"upper\", \"HELLO_WORLD\"),\n        (\"hello_world\", \"lower\", \"hello_world\"),\n    ];\n    \n    for (input, filter, expected) in test_cases {\n        // This would be tested in actual template rendering\n        // For now, we validate the filter names exist in templates\n        let template_content = include_str!(\"../../templates/rust-service.tmpl\");\n        assert!(template_content.contains(&format!(\"{{{{ name | {} }}}}\", filter)));\n    }\n}\n\n#[tokio::test]\nasync fn test_sparql_helpers() {\n    // Test that SPARQL helper functions are available\n    let template_content = include_str!(\"../../templates/rust-service.tmpl\");\n    \n    // Check for SPARQL helper usage\n    assert!(template_content.contains(\"sparql_count\"));\n    assert!(template_content.contains(\"sparql_first\"));\n    assert!(template_content.contains(\"sparql_values\"));\n    assert!(template_content.contains(\"sparql_results\"));\n}\n\n#[tokio::test]\nasync fn test_security_features() {\n    // Test that security features are implemented\n    let template_content = include_str!(\"../../templates/rust-service.tmpl\");\n    \n    // Check for security-related code\n    assert!(template_content.contains(\"Error::\"));\n    assert!(template_content.contains(\"Result<\"));\n    assert!(template_content.contains(\"anyhow::Result\"));\n    \n    // Check for input validation\n    assert!(template_content.contains(\"validation\"));\n    assert!(template_content.contains(\"required\"));\n}\n\n#[tokio::test]\nasync fn test_generated_code_structure() {\n    // Test that generated code has proper structure\n    let template_content = include_str!(\"../../templates/rust-service.tmpl\");\n    \n    // Check for Rust code structure\n    assert!(template_content.contains(\"use serde\"));\n    assert!(template_content.contains(\"use axum\"));\n    assert!(template_content.contains(\"pub struct\"));\n    assert!(template_content.contains(\"impl\"));\n    assert!(template_content.contains(\"#[tokio::test]\"));\n    \n    // Check for proper error handling\n    assert!(template_content.contains(\"thiserror::Error\"));\n    assert!(template_content.contains(\"anyhow::Result\"));\n}\n\n#[tokio::test]\nasync fn test_lifecycle_integration() {\n    // Test that lifecycle integration works\n    let make_content = include_str!(\"../../make.toml\");\n    \n    // Check for lifecycle phases\n    assert!(make_content.contains(\"[lifecycle.init]\"));\n    assert!(make_content.contains(\"[lifecycle.setup]\"));\n    assert!(make_content.contains(\"[lifecycle.generate]\"));\n    assert!(make_content.contains(\"[lifecycle.build]\"));\n    assert!(make_content.contains(\"[lifecycle.test]\"));\n    assert!(make_content.contains(\"[lifecycle.deploy]\"));\n    \n    // Check for dependencies\n    assert!(make_content.contains(\"depends_on\"));\n    assert!(make_content.contains(\"[\\\"setup\\\"]\"));\n    assert!(make_content.contains(\"[\\\"generate\\\"]\"));\n    assert!(make_content.contains(\"[\\\"build\\\"]\"));\n    assert!(make_content.contains(\"[\\\"test\\\"]\"));\n}\n\n#[tokio::test]\nasync fn test_configuration_files() {\n    // Test that configuration files are valid\n    let ggen_content = include_str!(\"../../ggen.toml\");\n    \n    // Check for project configuration\n    assert!(ggen_content.contains(\"[project]\"));\n    assert!(ggen_content.contains(\"name = \\\"advanced-rust-project\\\"\"));\n    assert!(ggen_content.contains(\"version = \\\"1.0.0\\\"\"));\n    \n    // Check for AI configuration\n    assert!(ggen_content.contains(\"[ai]\"));\n    assert!(ggen_content.contains(\"provider = \\\"openai\\\"\"));\n    assert!(ggen_content.contains(\"model = \\\"gpt-4\\\"\"));\n    \n    // Check for RDF configuration\n    assert!(ggen_content.contains(\"[rdf]\"));\n    assert!(ggen_content.contains(\"base_iri\"));\n    assert!(ggen_content.contains(\"default_format = \\\"turtle\\\"\"));\n    \n    // Check for security configuration\n    assert!(ggen_content.contains(\"[security]\"));\n    assert!(ggen_content.contains(\"validate_paths = true\"));\n    assert!(ggen_content.contains(\"block_shell_injection = true\"));\n}\n"
        }
    ]
}