MCPcopy Create free account
hub / github.com/astercloud/aster / TestToolCache_Delete

Function TestToolCache_Delete

pkg/tools/cache_test.go:272–305  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

270}
271
272func 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
307func TestToolCache_Clear(t *testing.T) {
308 config := &CacheConfig{

Callers

nothing calls this directly

Calls 4

SetMethod · 0.95
GetMethod · 0.95
DeleteMethod · 0.95
NewToolCacheFunction · 0.85

Tested by

no test coverage detected