guardy 0.2.4

Fast, secure git hooks in Rust with secret scanning and protected file synchronization
Documentation
//! Test the streaming Scanner implementation

use std::path::Path;

use anyhow::Result;
use guardy::scan::Scanner;

fn main() -> Result<()> {
    // Initialize logging
    tracing_subscriber::fmt()
        .with_env_filter("guardy=debug")
        .init();

    println!("Testing streaming Scanner implementation...\n");

    // Create scanner (uses CONFIG automatically)
    let scanner = Scanner::new()?;

    // Test 1: Scan current directory
    println!("Test 1: Scanning current directory...");
    let result = scanner.scan(&[Path::new(".").to_path_buf()])?;
    println!("  Files scanned: {}", result.files_scanned);
    println!("  Files skipped: {}", result.files_skipped);
    println!("  Processing errors: {}", result.processing_errors);
    println!("  Matches found: {}", result.total_matches);
    println!("  Duration: {} ms", result.scan_duration_ms);

    // Test 2: Scan src directory if it exists
    let src_dir = Path::new("src");
    if src_dir.exists() {
        println!("\nTest 2: Scanning src directory...");
        let src_result = scanner.scan(&[src_dir.to_path_buf()])?;
        println!("  Files scanned: {}", src_result.files_scanned);
        println!("  Files skipped: {}", src_result.files_skipped);
        println!("  Processing errors: {}", src_result.processing_errors);
        println!("  Matches found: {}", src_result.total_matches);
        println!("  Duration: {} ms", src_result.scan_duration_ms);
    }

    // Test 3: Scan tests directory if it exists
    let tests_dir = Path::new("tests");
    if tests_dir.exists() {
        println!("\nTest 3: Scanning tests directory...");
        let tests_result = scanner.scan(&[tests_dir.to_path_buf()])?;
        println!("  Files scanned: {}", tests_result.files_scanned);
        println!("  Files skipped: {}", tests_result.files_skipped);
        println!("  Processing errors: {}", tests_result.processing_errors);
        println!("  Matches found: {}", tests_result.total_matches);
        println!("  Duration: {} ms", tests_result.scan_duration_ms);
    }

    // Test 4: Check performance metrics from the initial scan
    if result.scan_duration_ms > 0 {
        println!("\nPerformance Summary (from initial scan):");
        println!(
            "  Files per second: {:.0}",
            result.files_scanned as f64 * 1000.0 / result.scan_duration_ms as f64
        );
    }

    Ok(())
}