#[cfg(feature = "http")]
mod uat_001_http_integration {
use sdforge::http::build;
#[test]
fn test_quick_http_integration() {
let app = build();
assert!(
!std::ptr::eq(&app, std::ptr::null()),
"HTTP quick integration should succeed"
);
}
}
#[cfg(feature = "mcp")]
mod uat_002_mcp_service {
use sdforge::mcp::build;
#[tokio::test]
async fn test_mcp_service_creation() {
let server = build();
assert!(
!std::ptr::eq(&server, std::ptr::null()),
"MCP service should build successfully"
);
}
}
#[cfg(all(feature = "http", feature = "mcp"))]
mod uat_003_dual_protocol {
use sdforge::http::build as http_build;
use sdforge::mcp::build as mcp_build;
#[tokio::test]
async fn test_dual_protocol_build() {
let http_result = http_build();
let mcp_result = mcp_build();
assert!(
!std::ptr::eq(&http_result, std::ptr::null()),
"HTTP build should succeed"
);
assert!(
!std::ptr::eq(&mcp_result, std::ptr::null()),
"MCP build should succeed"
);
}
}
#[cfg(feature = "http")]
mod uat_004_module_organization {
use sdforge::core::ApiMetadata;
#[test]
fn test_module_isolation() {
let metadata1 = ApiMetadata::new(
"auth/login".to_string(),
"v1".to_string(),
"Auth module".to_string(),
None,
false,
);
let metadata2 = ApiMetadata::new(
"users/profile".to_string(),
"v1".to_string(),
"Users module".to_string(),
None,
false,
);
assert_ne!(metadata1.name(), metadata2.name());
}
}
#[cfg(feature = "http")]
mod uat_007_nested_serialization {
use sdforge::core::ServiceResponse;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
struct Customer {
id: u64,
name: String,
}
#[derive(Serialize, Deserialize, Debug)]
struct Order {
id: u64,
customer: Customer,
}
#[test]
fn test_nested_serialization() {
let order = Order {
id: 1,
customer: Customer {
id: 100,
name: "Alice".to_string(),
},
};
let response = ServiceResponse::success(order);
let json = serde_json::to_string(&response).unwrap();
assert!(json.contains("id"));
assert!(json.contains("customer"));
}
}
#[cfg(feature = "http")]
mod uat_009_error_response {
use sdforge::core::ApiError;
#[test]
fn test_error_response_format() {
let errors: Vec<ApiError> = vec![
ApiError::NotFound {
resource: "User".to_string(),
resource_id: Some("123".to_string()),
},
ApiError::validation_error("email", "Invalid format"),
ApiError::InvalidInput {
message: "Query cannot be empty".to_string(),
field: Some("query".to_string()),
value: None,
},
];
for error in errors {
let json = serde_json::to_string(&error).unwrap();
assert!(json.contains("NotFound") || json.contains("InvalidInput"));
}
}
}
#[cfg(feature = "http")]
mod uat_010_version_management {
use sdforge::core::ApiMetadata;
#[test]
fn test_multiple_versions() {
let v1 = ApiMetadata::new(
"get_user".to_string(),
"v1".to_string(),
"Get user v1".to_string(),
None,
false,
);
let v2 = ApiMetadata::new(
"get_user".to_string(),
"v2".to_string(),
"Get user v2".to_string(),
None,
false,
);
assert_eq!(v1.name(), v2.name());
assert_eq!(v1.version(), "v1");
assert_eq!(v2.version(), "v2");
}
}
#[cfg(feature = "http")]
mod uat_011_performance {
use sdforge::core::ServiceResponse;
use std::time::Instant;
#[test]
fn test_response_creation_performance() {
let start = Instant::now();
for _ in 0..10000 {
let _response = ServiceResponse::success("test data".to_string());
}
let duration = start.elapsed();
assert!(
duration.as_millis() < 1000,
"Response creation should be fast"
);
}
}