(t *testing.T)
| 270 | } |
| 271 | |
| 272 | func TestToolCache_Delete(t *testing.T) { |
| 273 | config := &CacheConfig{ |
| 274 | Enabled: true, |
| 275 | Strategy: CacheStrategyMemory, |
| 276 | TTL: 1 * time.Hour, |
| 277 | } |
| 278 | |
| 279 | cache := NewToolCache(config) |
| 280 | ctx := context.Background() |
| 281 | key := "test_key" |
| 282 | value := "test_value" |
| 283 | |
| 284 | // 设置缓存 |
| 285 | err := cache.Set(ctx, key, value, config.TTL) |
| 286 | if err != nil { |
| 287 | t.Fatalf("Failed to set cache: %v", err) |
| 288 | } |
| 289 | |
| 290 | // 验证存在 |
| 291 | if _, ok := cache.Get(ctx, key); !ok { |
| 292 | t.Fatal("Expected cache hit") |
| 293 | } |
| 294 | |
| 295 | // 删除 |
| 296 | err = cache.Delete(key) |
| 297 | if err != nil { |
| 298 | t.Fatalf("Failed to delete cache: %v", err) |
| 299 | } |
| 300 | |
| 301 | // 验证已删除 |
| 302 | if _, ok := cache.Get(ctx, key); ok { |
| 303 | t.Fatal("Expected cache miss after deletion") |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | func TestToolCache_Clear(t *testing.T) { |
| 308 | config := &CacheConfig{ |
nothing calls this directly
no test coverage detected