mod config_tests;
mod set_tests;
mod spawn_tests;
mod tool_tests;
mod trust_tests;
pub(super) mod support {
use std::path::{Path, PathBuf};
use trusty_mcp::config::{McpServerConfig, McpTransport};
pub(crate) fn global_file(dir: &Path, text: &str) -> PathBuf {
let path = dir.join("servers.toml");
std::fs::write(&path, text).expect("writing the global fixture");
path
}
pub(crate) fn project_file(project: &Path, text: &str) -> PathBuf {
let dir = project.join(crate::paths::TRUSTY_CODE_DIRNAME);
std::fs::create_dir_all(&dir).expect("creating the project config dir");
let path = dir.join(super::super::config::PROJECT_MCP_FILE);
std::fs::write(&path, text).expect("writing the project fixture");
path
}
pub(crate) fn one_stdio_server(name: &str, command: &str) -> String {
format!(
"[[servers]]\nname = {name:?}\n[servers.transport]\ntype = \"stdio\"\ncommand = {command:?}\n"
)
}
pub(crate) fn stdio(name: &str, command: &str, args: &[&str]) -> McpServerConfig {
McpServerConfig::new(
name,
McpTransport::Stdio {
command: command.to_string(),
args: args.iter().map(|a| a.to_string()).collect(),
env: std::collections::BTreeMap::new(),
},
)
}
}