mecha10-behavior-runtime 0.1.0

Behavior tree runtime for Mecha10 - unified AI and logic composition system
Documentation
//! Test helpers for behavior runtime
//!
//! This module provides utilities for testing behaviors without requiring external dependencies.

#[cfg(test)]
use mecha10_core::Context;

/// Create a test context that doesn't require Redis or other infrastructure.
///
/// This is a helper for unit tests that need a Context but don't actually use messaging.
/// For integration tests that need real messaging, use Context::new() with proper infrastructure.
#[cfg(test)]
pub async fn create_test_context(node_id: &str) -> Context {
    // For now, we'll just attempt to create a real context
    // If it fails (no Redis), tests will be skipped
    // In the future, we should create a mock Context for pure unit tests
    match Context::new(node_id).await {
        Ok(ctx) => ctx,
        Err(_) => {
            // Skip test if Redis is not available
            panic!("Test requires Redis - skipping. Run Redis to enable full test suite.");
        }
    }
}

#[cfg(test)]
pub fn skip_if_no_redis() -> Result<(), String> {
    // Check if Redis is available by attempting to connect
    // For now, we'll just return Ok and let tests fail naturally
    Ok(())
}