godot-testability-runtime 0.1.2

Embedded Godot runtime for comprehensive Rust testing
Documentation
//! Tests for the godot-testability-runtime itself.
//!
//! These tests verify that the runtime can initialize and manage
//! the embedded Godot engine without depending on any specific
//! godot-rust version.

use godot_testability_runtime::prelude::*;
use godot_testability_runtime::runtime::UserCallbacks;

#[test]
fn test_runtime_initialization() {
    // Test that we can check runtime state
    assert!(!GodotRuntime::is_initialized());
    assert!(!GodotRuntime::is_running());
}

#[test]
fn test_runtime_shutdown() {
    // Test that shutdown works even when not initialized
    let result = GodotRuntime::shutdown();
    assert!(result.is_ok());
}

#[test]
fn test_runtime_config_default() {
    let config = RuntimeConfig::default();
    assert!(config.headless);
    assert!(!config.verbose);
    assert!(config.custom_args.is_empty());
}

#[test]
fn test_runtime_config_custom() {
    let config = RuntimeConfig {
        headless: false,
        verbose: true,
        custom_args: vec!["--test".to_string()],
    };
    assert!(!config.headless);
    assert!(config.verbose);
    assert_eq!(config.custom_args.len(), 1);
}

#[test]
fn test_error_types() {
    use godot_testability_runtime::error::TestError;

    let err = TestError::assertion("test failed");
    assert!(format!("{}", err).contains("Assertion failed"));

    let err = TestError::failure("custom failure");
    assert!(format!("{}", err).contains("Test failed"));
}

// Integration test that actually runs the runtime
// This test is ignored by default since it requires libgodot
#[test]
#[ignore]
fn test_runtime_execution() {
    let config = RuntimeConfig::default();

    // Mock callbacks that don't actually initialize godot
    let callbacks = UserCallbacks {
        initialize_ffi: |_, _| Ok(()),
        load_class_method_table: |_| {},
        register_classes: None,
    };

    // This would normally run but we can't test it without libgodot
    // The test is here to ensure the API is correct
    let _ = config;
    let _ = callbacks;
}