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

Function TestToolCache_Disabled

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

Source from the content-addressed store, hash-verified

476}
477
478func 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
508func TestToolCache_Cleanup(t *testing.T) {
509 config := &CacheConfig{

Callers

nothing calls this directly

Calls 4

SetMethod · 0.95
GetMethod · 0.95
GetStatsMethod · 0.95
NewToolCacheFunction · 0.85

Tested by

no test coverage detected