Files
Serendipity 1a1254f045
CI - 构建、测试和质量检查 / Rust 代码检查 (push) Has been cancelled
CI - 构建、测试和质量检查 / 单元测试 (push) Has been cancelled
CI - 构建、测试和质量检查 / 代码格式检查 (push) Has been cancelled
CI - 构建、测试和质量检查 / Clippy 代码质量检查 (push) Has been cancelled
CI - 构建、测试和质量检查 / 构建可执行文件 (claude_code_rs, macos-latest, x86_64-apple-darwin) (push) Has been cancelled
CI - 构建、测试和质量检查 / 构建可执行文件 (claude_code_rs, ubuntu-latest, x86_64-unknown-linux-gnu) (push) Has been cancelled
CI - 构建、测试和质量检查 / 构建可执行文件 (claude_code_rs.exe, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
feat: 添加初始项目结构和基础文件
- 添加 Rust GUI 桌面应用程序入口点
- 添加 TypeScript/JavaScript 项目基础结构文件
- 包含组件、工具、命令、服务和工具定义
- 添加配置文件如 .gitignore、.gitattributes 和 LICENSE
- 包含图片资源和演示文件
- 为各种功能模块添加占位符和类型定义
2026-04-20 16:58:22 +08:00

96 lines
2.5 KiB
Rust

//! Tests for Tools Module
use claude_code_rs::tools::{ToolRegistry, ToolOutput};
#[tokio::test]
async fn test_tool_registry_creation() {
let registry = ToolRegistry::new();
let tools = registry.list();
// Should have 9 tools now (6 original + 3 new)
assert!(tools.len() >= 6);
}
#[tokio::test]
async fn test_file_read_tool() {
let registry = ToolRegistry::new();
let tool = registry.get("file_read").expect("file_read tool should exist");
assert_eq!(tool.name(), "file_read");
assert!(!tool.description().is_empty());
}
#[tokio::test]
async fn test_git_operations_tool() {
let registry = ToolRegistry::new();
let tool = registry.get("git_operations").expect("git_operations tool should exist");
assert_eq!(tool.name(), "git_operations");
assert!(tool.description().contains("Git"));
}
#[tokio::test]
async fn test_task_management_tool() {
let registry = ToolRegistry::new();
let tool = registry.get("task_management").expect("task_management tool should exist");
assert_eq!(tool.name(), "task_management");
assert!(tool.description().contains("task"));
}
#[tokio::test]
async fn test_note_edit_tool() {
let registry = ToolRegistry::new();
let tool = registry.get("note_edit").expect("note_edit tool should exist");
assert_eq!(tool.name(), "note_edit");
assert!(tool.description().contains("note"));
}
#[tokio::test]
async fn test_task_create_and_list() {
use serde_json::json;
let registry = ToolRegistry::new();
// Create a task
let create_result = registry.execute("task_management", json!({
"operation": "create",
"subject": "Test Task",
"description": "This is a test task"
})).await;
assert!(create_result.is_ok());
// List tasks
let list_result = registry.execute("task_management", json!({
"operation": "list"
})).await;
assert!(list_result.is_ok());
}
#[tokio::test]
async fn test_note_create_and_search() {
use serde_json::json;
let registry = ToolRegistry::new();
// Create a note
let create_result = registry.execute("note_edit", json!({
"operation": "create",
"title": "Test Note",
"content": "This is a test note content",
"tags": ["test", "example"]
})).await;
assert!(create_result.is_ok());
// Search notes
let search_result = registry.execute("note_edit", json!({
"operation": "search",
"search_query": "test"
})).await;
assert!(search_result.is_ok());
}