pmat 3.15.0

PMAT - Zero-config AI context generation and code quality toolkit (CLI, MCP, HTTP)
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod tests {
    use super::*;

    #[tokio::test]
    async fn test_harness_creation() {
        let harness = TestHarness::new();
        assert_eq!(harness.test_results.lock().await.tests_run, 0);
    }

    #[tokio::test]
    async fn test_template_generation_endpoint() {
        let harness = TestHarness::new();

        // This test may fail if the default services don't implement the expected behavior
        // But it should demonstrate the test harness functionality
        let result = harness.test_template_generation().await;

        // We expect this to work with the default template service
        match result {
            Ok(()) => println!("Template generation test passed"),
            Err(e) => println!("Template generation test failed (expected): {}", e),
        }
    }

    #[tokio::test]
    async fn test_error_handling_consistency() {
        let harness = TestHarness::new();

        // Test error handling across protocols
        let result = harness.test_error_handling().await;

        match result {
            Ok(()) => println!("Error handling test passed"),
            Err(e) => println!("Error handling test failed: {}", e),
        }
    }

    #[tokio::test]
    async fn test_protocol_equivalence() {
        let harness = TestHarness::new();

        // Run a simple test to verify protocol equivalence logic
        let body = json!({"test": "value"});

        let result = harness
            .test_endpoint::<_, Value>("simple_test", "GET", "/health", body)
            .await;

        match result {
            Ok(()) => println!("Protocol equivalence test passed"),
            Err(e) => println!("Protocol equivalence test failed: {}", e),
        }
    }

    #[test]
    fn test_suite_results() {
        let mut results = TestSuiteResults::new();
        assert_eq!(results.success_rate(), 0.0);
        assert!(results.is_successful());

        results.passed.push("test1".to_string());
        results
            .failed
            .push(("test2".to_string(), "error".to_string()));

        assert_eq!(results.success_rate(), 0.5);
        assert!(!results.is_successful());
    }
}