diff --git a/tests/db_test.rs b/tests/db_test.rs index 42ef2e2..772a2bd 100644 --- a/tests/db_test.rs +++ b/tests/db_test.rs @@ -60,6 +60,23 @@ async fn test_database_pragma_foreign_keys() { assert_eq!(foreign_keys, 1); } +#[tokio::test] +async fn test_database_pragma_busy_timeout() { + let db = Database::open_in_memory().await.unwrap(); + + let conn = db.connection(); + let busy_timeout = conn + .call(|c| { + let mut stmt = c.prepare("PRAGMA busy_timeout")?; + let value: i32 = stmt.query_row([], |row| row.get::<_, i32>(0))?; + Ok(value) + }) + .await + .unwrap(); + + assert_eq!(busy_timeout, 5000); +} + #[tokio::test] async fn test_database_schema_tables_exist() { let db = Database::open_in_memory().await.unwrap(); diff --git a/tests/graph_tools_test.rs b/tests/graph_tools_test.rs index f1602c5..0461a87 100644 --- a/tests/graph_tools_test.rs +++ b/tests/graph_tools_test.rs @@ -3,9 +3,16 @@ use rustagent::graph::store::{GraphStore, SqliteGraphStore}; use rustagent::graph::{EdgeType, NodeStatus, NodeType}; use rustagent::tools::Tool; use rustagent::tools::graph_tools::*; +use rustagent::tools::factory::create_v2_registry; +use rustagent::security::SecurityValidator; +use rustagent::security::permission::AutoApproveHandler; +use rustagent::config::SecurityConfig; use serde_json::{Value, json}; use std::sync::Arc; +mod common; +use common::MockGraphStore; + /// Create a test database in memory with a test project async fn setup_test_db() -> anyhow::Result<(Database, Arc)> { let db = Database::open_in_memory().await?; @@ -637,3 +644,60 @@ async fn test_tool_name_and_description() -> anyhow::Result<()> { Ok(()) } + +#[test] +fn test_v2_registry_includes_all_tools() { + // Create a mock graph store + let graph_store = Arc::new(MockGraphStore); + + // Create security config and validator + let security_config = SecurityConfig { + shell_policy: rustagent::config::ShellPolicy::Blocklist, + allowed_commands: vec![], + blocked_patterns: vec![], + max_file_size_mb: 100, + allowed_paths: vec![], + }; + let validator = Arc::new(SecurityValidator::new(security_config).expect("Failed to create validator")); + let permission_handler = Arc::new(AutoApproveHandler); + + // Create the v2 registry + let registry = create_v2_registry(validator, permission_handler, graph_store); + + // Expected tool names: graph tools + legacy tools + context tools + let expected_tools = vec![ + // Graph tools + "create_node", + "update_node", + "add_edge", + "query_nodes", + "search_nodes", + "claim_task", + "log_decision", + "choose_option", + "record_outcome", + "record_observation", + "revisit", + // Legacy tools + "read_file", + "write_file", + "list_files", + "run_command", + "signal_completion", + // Context tools + "read_agents_md", + ]; + + // Get all registered tool names + let registered_names = registry.list(); + + // Verify each expected tool is registered + for expected in expected_tools { + assert!( + registered_names.contains(&expected.to_string()), + "Tool '{}' not found in v2 registry. Registered tools: {:?}", + expected, + registered_names + ); + } +}