//! Tests for MCP Transport configuration (McpServerConfig) //! //! These tests cover McpServerConfig builder methods without spawning processes. use std::collections::HashMap; use zclaw_protocols::McpServerConfig; #[test] fn npx_config_creates_correct_command() { let config = McpServerConfig::npx("@modelcontextprotocol/server-memory"); assert_eq!(config.command, "npx"); assert_eq!(config.args, vec!["-y", "@modelcontextprotocol/server-memory"]); assert!(config.env.is_empty()); assert!(config.cwd.is_none()); } #[test] fn node_config_creates_correct_command() { let config = McpServerConfig::node("/path/to/server.js"); assert_eq!(config.command, "node"); assert_eq!(config.args, vec!["/path/to/server.js"]); } #[test] fn python_config_creates_correct_command() { let config = McpServerConfig::python("mcp_server.py"); assert_eq!(config.command, "python"); assert_eq!(config.args, vec!["mcp_server.py"]); } #[test] fn env_adds_variables() { let config = McpServerConfig::node("server.js") .env("API_KEY", "secret123") .env("DEBUG", "true"); assert_eq!(config.env.get("API_KEY").unwrap(), "secret123"); assert_eq!(config.env.get("DEBUG").unwrap(), "true"); } #[test] fn cwd_sets_working_directory() { let config = McpServerConfig::node("server.js").cwd("/tmp/work"); assert_eq!(config.cwd.unwrap(), "/tmp/work"); } #[test] fn combined_builder_pattern() { let config = McpServerConfig::npx("@scope/server") .env("PORT", "3000") .cwd("/app"); assert_eq!(config.command, "npx"); assert_eq!(config.args.len(), 2); assert_eq!(config.env.len(), 1); assert_eq!(config.cwd.unwrap(), "/app"); }