mechutil 0.8.1

Utility structures and functions for mechatronics applications.
Documentation
use mechutil::ipc::{BaseModuleHandler, CommandMessage, ModuleHandler};
use serde_json::Value;

#[tokio::test]
async fn test_get_catalog() {
    let mut handler = BaseModuleHandler::new("test.module");
    
    // Register FQDNs
    handler.register_fqdn("test.module.var1".to_string());
    handler.register_fqdn("test.module.var2".to_string());
    
    // Case 1: Matching get_catalog
    let msg = CommandMessage::request("test_module.get_catalog", Value::Null);
    let response = handler.handle_message(msg).await;
    
    assert!(response.success, "Response should be successful");
    
    let catalog: Vec<String> = serde_json::from_value(response.data).expect("Data should be a list of strings");
    assert_eq!(catalog.len(), 2);
    assert!(catalog.contains(&"test.module.var1".to_string()));
    assert!(catalog.contains(&"test.module.var2".to_string()));

    // Case 2: Non-matching command
    let msg_other = CommandMessage::request("test_module.other_command", Value::Null);
    let response_other = handler.handle_message(msg_other).await;
    
    assert!(!response_other.success, "Unknown command should fail");
    assert!(response_other.error_message.contains("not implemented"));
}