test(protocols,skills): add 90 tests for MCP types + skill loader/runner
zclaw-protocols: +43 tests covering mcp_types serde, ContentBlock variants, transport config builders, and domain type roundtrips. zclaw-skills: +47 tests covering SKILL.md/TOML parsing, auto-classify, PromptOnlySkill execution, and SkillManifest/SkillResult roundtrips. Batch 8 of audit plan (plans/stateless-petting-rossum.md).
This commit is contained in:
55
crates/zclaw-protocols/tests/mcp_transport_tests.rs
Normal file
55
crates/zclaw-protocols/tests/mcp_transport_tests.rs
Normal file
@@ -0,0 +1,55 @@
|
||||
//! 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");
|
||||
}
|
||||
Reference in New Issue
Block a user