use anyhow::Result;
use pmat::cli::handlers::wasm_handlers::handle_analyze_webassembly;
use pmat::cli::ComplexityOutputFormat;
use tempfile::tempdir;
#[tokio::test]
async fn test_webassembly_handler_structure() -> Result<()> {
let temp_dir = tempdir()?;
let project_path = temp_dir.path().to_path_buf();
let wasm_file = project_path.join("test.wasm");
tokio::fs::write(&wasm_file, b"fake wasm content").await?;
let wat_file = project_path.join("test.wat");
tokio::fs::write(&wat_file, "(module)").await?;
let _result = handle_analyze_webassembly(
project_path,
ComplexityOutputFormat::Json,
true, true, false, false, false, None, false, )
.await;
Ok(())
}
#[tokio::test]
async fn test_security_and_complexity_flags() -> Result<()> {
let temp_dir = tempdir()?;
let project_path = temp_dir.path().to_path_buf();
let wat_file = project_path.join("module.wat");
tokio::fs::write(&wat_file, "(module (func))").await?;
let _result = handle_analyze_webassembly(
project_path.clone(),
ComplexityOutputFormat::Json,
false, true, false, true, true, None,
true, )
.await;
Ok(())
}
#[tokio::test]
async fn test_output_file_handling() -> Result<()> {
let temp_dir = tempdir()?;
let project_path = temp_dir.path().to_path_buf();
let output_file = temp_dir.path().join("output.json");
let _result = handle_analyze_webassembly(
project_path,
ComplexityOutputFormat::Json,
false,
false,
false,
false,
false,
Some(output_file),
false,
)
.await;
Ok(())
}