(t *testing.T)
| 343 | } |
| 344 | |
| 345 | func TestToolCache_GenerateKey(t *testing.T) { |
| 346 | cache := NewToolCache(DefaultCacheConfig()) |
| 347 | |
| 348 | // 相同输入应该生成相同的键 |
| 349 | input1 := map[string]any{"a": 1, "b": "test"} |
| 350 | input2 := map[string]any{"a": 1, "b": "test"} |
| 351 | |
| 352 | key1 := cache.GenerateKey("tool1", input1) |
| 353 | key2 := cache.GenerateKey("tool1", input2) |
| 354 | |
| 355 | if key1 != key2 { |
| 356 | t.Errorf("Expected same key for same input, got: %s != %s", key1, key2) |
| 357 | } |
| 358 | |
| 359 | // 不同输入应该生成不同的键 |
| 360 | input3 := map[string]any{"a": 2, "b": "test"} |
| 361 | key3 := cache.GenerateKey("tool1", input3) |
| 362 | |
| 363 | if key1 == key3 { |
| 364 | t.Error("Expected different key for different input") |
| 365 | } |
| 366 | |
| 367 | // 不同工具名应该生成不同的键 |
| 368 | key4 := cache.GenerateKey("tool2", input1) |
| 369 | |
| 370 | if key1 == key4 { |
| 371 | t.Error("Expected different key for different tool name") |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | func TestCachedTool_Execute(t *testing.T) { |
| 376 | config := &CacheConfig{ |
nothing calls this directly
no test coverage detected