//! Tests for GodotCollector

use mecha10_diagnostics::collectors::godot::GodotCollector;
use std::sync::atomic::Ordering;

#[test]
fn test_godot_collector_connection_tracking() {
    let collector = GodotCollector::new(
        "test",
        "ws://localhost:11008".to_string(),
        "ws://localhost:11009".to_string(),
    );

    // Initial state
    assert_eq!(collector.control_connected.load(Ordering::Relaxed), 0);

    // Connect
    collector.set_control_connected(true);
    assert_eq!(collector.control_connected.load(Ordering::Relaxed), 1);

    // Disconnect
    collector.set_control_connected(false);
    assert_eq!(collector.control_connected.load(Ordering::Relaxed), 0);
}

#[test]
fn test_godot_collector_reconnect_counting() {
    let collector = GodotCollector::new(
        "test",
        "ws://localhost:11008".to_string(),
        "ws://localhost:11009".to_string(),
    );

    // Record some frames to indicate we're past initial startup
    collector.record_frame();
    collector.record_frame();

    // First connect (not a reconnect)
    collector.set_control_connected(true);
    assert_eq!(collector.control_reconnects.get(), 0);

    // Disconnect and reconnect (this is a reconnect)
    collector.set_control_connected(false);
    collector.set_control_connected(true);
    assert_eq!(collector.control_reconnects.get(), 1);
}
