#[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();
let result = harness.test_template_generation().await;
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();
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();
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());
}
}