MCPcopy Create free account
hub / github.com/AI45Lab/Code / test_registry_execute_with_context_success

Function test_registry_execute_with_context_success

core/src/tools/registry.rs:430–454  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

428
429 #[tokio::test]
430 async fn test_registry_execute_with_context_success() {
431 let registry = ToolRegistry::new(PathBuf::from("/tmp"));
432 let ctx = ToolContext::new(PathBuf::from("/tmp"));
433 let trace_sink = InMemoryTraceSink::default();
434 registry.set_trace_sink(Arc::new(trace_sink.clone()));
435
436 registry.register(Arc::new(MockTool {
437 name: "my_tool".to_string(),
438 }));
439
440 let result = registry
441 .execute_with_context("my_tool", &serde_json::json!({}), &ctx)
442 .await
443 .unwrap();
444 assert_eq!(result.name, "my_tool");
445 assert_eq!(result.exit_code, 0);
446 assert_eq!(result.output, "mock output");
447
448 let events = trace_sink.events();
449 assert_eq!(events.len(), 1);
450 assert_eq!(events[0].kind, TraceEventKind::ToolExecution);
451 assert_eq!(events[0].name, "my_tool");
452 assert!(events[0].success);
453 assert_eq!(events[0].output_bytes, "mock output".len());
454 }
455
456 #[tokio::test]
457 async fn test_registry_execute_with_context_unknown_tool() {

Callers

nothing calls this directly

Calls 5

set_trace_sinkMethod · 0.45
cloneMethod · 0.45
registerMethod · 0.45
execute_with_contextMethod · 0.45
eventsMethod · 0.45

Tested by

no test coverage detected