use markbase::raid::{RaidController, RaidLevel};
use std::path::PathBuf;

fn main() {
    println!("=== RAID 0 Test ===");
    println!("");
    
    let controller = RaidController::new();
    
    let members = vec![
        PathBuf::from("data/raid_test/disk1.sparseimage"),
        PathBuf::from("data/raid_test/disk2.sparseimage"),
        PathBuf::from("data/raid_test/disk3.sparseimage"),
    ];
    
    println!("Creating RAID 0 array with 3 members...");
    let array_id = controller.create_array(
        RaidLevel::RAID0,
        members,
        64 * 1024, // 64KB stripe size
    );
    
    match array_id {
        Ok(id) => {
            println!("✅ RAID array created: {}", id);
            println!("Stripe size: 64KB");
            println!("Expected total size: 15GB");
            println!("");
            println!("Testing read/write operations...");
            
            let test_data = b"Hello RAID 0!";
            let write_result = controller.write(&id, 0, test_data);
            
            match write_result {
                Ok(_) => {
                    println!("✅ Write successful");
                    
                    let read_result = controller.read(&id, 0, test_data.len() as u64);
                    match read_result {
                        Ok(data) => {
                            println!("✅ Read successful");
                            println!("Data: {:?}", data);
                            println!("");
                            println!("🎉 RAID 0 is working!");
                        },
                        Err(e) => println!("❌ Read failed: {}", e),
                    }
                },
                Err(e) => println!("❌ Write failed: {}", e),
            }
        },
        Err(e) => println!("❌ Failed to create RAID array: {}", e),
    }
}
