#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod coverage_tests {
use super::*;
fn fixture_dir() -> tempfile::TempDir {
let dir = tempfile::TempDir::new().expect("tempdir");
std::fs::write(
dir.path().join("sample.rs"),
"fn sample(a: i32) -> i32 {\n if a > 2 {\n a * 3\n } else {\n a\n }\n}\n",
)
.expect("write fixture");
dir
}
use serde_json::json;
use tokio_util::sync::CancellationToken;
fn test_extra() -> RequestHandlerExtra {
RequestHandlerExtra::new("test-request".to_string(), CancellationToken::new())
}
#[test]
fn test_complexity_tool_new() {
let tool = ComplexityTool::new();
let _ = tool;
}
#[test]
fn test_complexity_tool_default() {
let tool = ComplexityTool;
let _ = tool;
}
#[tokio::test]
async fn test_complexity_tool_invalid_args() {
let tool = ComplexityTool::new();
let args = json!({"invalid": "args"});
let result = tool.handle(args, test_extra()).await;
assert!(result.is_err());
}
#[tokio::test]
async fn test_complexity_tool_empty_paths() {
let tool = ComplexityTool::new();
let args = json!({"paths": []});
let result = tool.handle(args, test_extra()).await;
assert!(result.is_err());
}
#[tokio::test]
async fn test_complexity_tool_with_all_options() {
let tool = ComplexityTool::new();
let fixture = fixture_dir();
let fixture_dir_path = fixture.path().display().to_string();
let args = json!({
"paths": [fixture_dir_path.as_str()],
"top_files": 5,
"threshold": 15
});
let result = tool.handle(args, test_extra()).await;
assert!(result.is_ok());
}
#[test]
fn test_satd_tool_new() {
let tool = SatdTool::new();
let _ = tool;
}
#[test]
fn test_satd_tool_default() {
let tool = SatdTool;
let _ = tool;
}
#[tokio::test]
async fn test_satd_tool_invalid_args() {
let tool = SatdTool::new();
let args = json!({"invalid": "args"});
let result = tool.handle(args, test_extra()).await;
assert!(result.is_err());
}
#[tokio::test]
async fn test_satd_tool_empty_paths() {
let tool = SatdTool::new();
let args = json!({"paths": []});
let result = tool.handle(args, test_extra()).await;
assert!(result.is_err());
}
#[tokio::test]
async fn test_satd_tool_with_include_resolved() {
let tool = SatdTool::new();
let fixture = fixture_dir();
let fixture_dir_path = fixture.path().display().to_string();
let args = json!({
"paths": [fixture_dir_path.as_str()],
"include_resolved": true
});
let result = tool.handle(args, test_extra()).await;
assert!(result.is_ok());
}
#[test]
fn test_dead_code_tool_new() {
let tool = DeadCodeTool::new();
let _ = tool;
}
#[test]
fn test_dead_code_tool_default() {
let tool = DeadCodeTool;
let _ = tool;
}
#[tokio::test]
async fn test_dead_code_tool_invalid_args() {
let tool = DeadCodeTool::new();
let args = json!({"invalid": "args"});
let result = tool.handle(args, test_extra()).await;
assert!(result.is_err());
}
#[tokio::test]
async fn test_dead_code_tool_empty_paths() {
let tool = DeadCodeTool::new();
let args = json!({"paths": []});
let result = tool.handle(args, test_extra()).await;
assert!(result.is_err());
}
#[tokio::test]
async fn test_dead_code_tool_with_include_tests() {
let tool = DeadCodeTool::new();
let fixture = fixture_dir();
let fixture_dir_path = fixture.path().display().to_string();
let args = json!({
"paths": [fixture_dir_path.as_str()],
"include_tests": true
});
let result = tool.handle(args, test_extra()).await;
assert!(result.is_ok());
}
#[test]
fn test_lint_hotspot_tool_new() {
let tool = LintHotspotTool::new();
let _ = tool;
}
#[test]
fn test_lint_hotspot_tool_default() {
let tool = LintHotspotTool;
let _ = tool;
}
#[tokio::test]
async fn test_lint_hotspot_tool_invalid_args() {
let tool = LintHotspotTool::new();
let args = json!({"invalid": "args"});
let result = tool.handle(args, test_extra()).await;
assert!(result.is_err());
}
#[tokio::test]
async fn test_lint_hotspot_tool_empty_paths() {
let tool = LintHotspotTool::new();
let args = json!({"paths": []});
let result = tool.handle(args, test_extra()).await;
assert!(result.is_err());
}
#[tokio::test]
async fn test_lint_hotspot_tool_with_top_files() {
let tool = LintHotspotTool::new();
let args = json!({
"paths": ["/nonexistent/path"],
"top_files": 5
});
let result = tool.handle(args, test_extra()).await;
assert!(result.is_err());
}
#[test]
fn test_churn_tool_new() {
let tool = ChurnTool::new();
let _ = tool;
}
#[test]
fn test_churn_tool_default() {
let tool = ChurnTool;
let _ = tool;
}
#[tokio::test]
async fn test_churn_tool_invalid_args() {
let tool = ChurnTool::new();
let args = json!({"invalid": "args"});
let result = tool.handle(args, test_extra()).await;
assert!(result.is_err());
}
#[tokio::test]
async fn test_churn_tool_empty_paths() {
let tool = ChurnTool::new();
let args = json!({"paths": []});
let result = tool.handle(args, test_extra()).await;
assert!(result.is_err());
}
#[tokio::test]
async fn test_churn_tool_with_all_options() {
let tool = ChurnTool::new();
let args = json!({
"paths": ["/nonexistent/path"],
"days": 30,
"top_files": 10
});
let result = tool.handle(args, test_extra()).await;
assert!(result.is_err());
}
#[test]
fn test_coupling_tool_new() {
let tool = CouplingTool::new();
let _ = tool;
}
#[test]
fn test_coupling_tool_default() {
let tool = CouplingTool;
let _ = tool;
}
#[tokio::test]
async fn test_coupling_tool_invalid_args() {
let tool = CouplingTool::new();
let args = json!({"invalid": "args"});
let result = tool.handle(args, test_extra()).await;
assert!(result.is_err());
}
#[tokio::test]
async fn test_coupling_tool_empty_paths() {
let tool = CouplingTool::new();
let args = json!({"paths": []});
let result = tool.handle(args, test_extra()).await;
assert!(result.is_err());
}
#[tokio::test]
async fn test_coupling_tool_with_threshold() {
let tool = CouplingTool::new();
let args = json!({
"paths": ["/nonexistent/path"],
"threshold": 0.5
});
let result = tool.handle(args, test_extra()).await;
assert!(result.is_err());
}
}