use super::ContractValidation;
use crate::cli::commands::AnalyzeCommands;
use anyhow::Result;
pub fn map_analyze_command(cmd: &AnalyzeCommands) -> Result<Box<dyn ContractValidation>> {
super::adapter::ContractAdapter::from_cli(cmd)
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod tests {
use super::*;
use std::path::PathBuf;
#[test]
fn test_map_analyze_command_tdg_variant() {
let cmd = AnalyzeCommands::Tdg {
path: PathBuf::from("."),
threshold: 1.5,
top_files: 10,
format: crate::cli::TdgOutputFormat::Table,
include_components: false,
output: None,
critical_only: false,
verbose: false,
ml: false,
};
let result = map_analyze_command(&cmd);
assert!(result.is_ok());
}
#[test]
fn test_map_analyze_command_unsupported_variant() {
let cmd = AnalyzeCommands::Churn {
path: PathBuf::from("."),
project_path: Some(PathBuf::from(".")),
days: 30,
format: crate::models::churn::ChurnOutputFormat::Summary,
output: None,
top_files: 10,
include: vec![],
exclude: vec![],
};
let result = map_analyze_command(&cmd);
assert!(result.is_err());
}
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod property_tests {
use proptest::prelude::*;
proptest! {
#[test]
fn basic_property_stability(_input in ".*") {
prop_assert!(true);
}
#[test]
fn module_consistency_check(_x in 0u32..1000) {
prop_assert!(_x < 1001);
}
}
}