(t *testing.T)
| 476 | } |
| 477 | |
| 478 | func TestToolCache_Disabled(t *testing.T) { |
| 479 | config := &CacheConfig{ |
| 480 | Enabled: false, |
| 481 | Strategy: CacheStrategyMemory, |
| 482 | TTL: 1 * time.Hour, |
| 483 | } |
| 484 | |
| 485 | cache := NewToolCache(config) |
| 486 | ctx := context.Background() |
| 487 | key := "test_key" |
| 488 | value := "test_value" |
| 489 | |
| 490 | // 设置缓存(应该被忽略) |
| 491 | err := cache.Set(ctx, key, value, config.TTL) |
| 492 | if err != nil { |
| 493 | t.Fatalf("Failed to set cache: %v", err) |
| 494 | } |
| 495 | |
| 496 | // 获取缓存(应该失败) |
| 497 | if _, ok := cache.Get(ctx, key); ok { |
| 498 | t.Fatal("Expected cache miss when disabled") |
| 499 | } |
| 500 | |
| 501 | // 统计应该为0 |
| 502 | stats := cache.GetStats() |
| 503 | if stats.Sets != 0 { |
| 504 | t.Errorf("Expected 0 sets when disabled, got: %d", stats.Sets) |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | func TestToolCache_Cleanup(t *testing.T) { |
| 509 | config := &CacheConfig{ |
nothing calls this directly
no test coverage detected