// Tests for mecha10_cli::services::init_service

use mecha10_cli::services::init_service::*;

use tempfile::TempDir;

#[test]
fn test_init_service_creation() {
    let _service = InitService::new();
    // Service creation succeeds if we reach here without panic
}

#[tokio::test]
async fn test_create_project_directories() -> Result<()> {
    let temp = TempDir::new()?;
    let service = InitService::new();

    service.create_project_directories(temp.path()).await?;

    // Check all directories were created
    assert!(temp.path().join("nodes").exists());
    assert!(temp.path().join("drivers").exists());
    assert!(temp.path().join("types").exists());
    assert!(temp.path().join("behaviors").exists());
    assert!(temp.path().join("config").exists());
    assert!(temp.path().join("logs").exists());
    assert!(temp.path().join("simulation").exists());

    // Check .gitkeep files were created
    assert!(temp.path().join("nodes").join(".gitkeep").exists());
    assert!(temp.path().join("drivers").join(".gitkeep").exists());

    Ok(())
}

#[test]
fn test_detect_framework_path_not_in_monorepo() {
    let service = InitService::new();

    // When not in monorepo, this should return an error
    let result = service.detect_framework_path();
    assert!(result.is_err());
}
