Files
OpenFlare/backend/plugins/infra/storage/diskcache/cache_test.go
T
ryan 9f8890d159 refactor(module): simplify module name to Wavelet and standardize import paths
- Declared module Wavelet in backend/go.mod
- Replaced github.com/Rain-kl/Wavelet/ with clean Wavelet/ import paths across backend codebase
- Updated architecture guards, Makefile, swagger, and build tests
- 100% passed all tests, lint checks, and binary compilation
2026-08-28 13:10:30 +08:00

50 lines
1.3 KiB
Go

// Copyright 2026 Arctel.net
// SPDX-License-Identifier: Apache-2.0
package diskcache
import (
"context"
"os"
"testing"
"Wavelet/pkg/testhelper"
cache "Wavelet/plugins/infra/cache"
)
func TestDiskCacheReloadConfig(t *testing.T) {
dbConn, _, cleanup := testhelper.SetupTestEnvironment(t)
defer cleanup()
testDir := "uploads/test_diskcache_reload"
defer func() { _ = os.RemoveAll(testDir) }()
_ = os.RemoveAll(testDir)
c := New(testDir)
defer func() { _ = c.Clear() }()
// Update DB config values
dbConn.Table("w_system_configs").Where("key = ?", "disk_cache_max_size_mb").Update("value", "250")
dbConn.Table("w_system_configs").Where("key = ?", "disk_cache_ttl_minutes").Update("value", "120")
dbConn.Table("w_system_configs").Where("key = ?", "disk_cache_lru_enabled").Update("value", "false")
// Invalidate Redis config cache to force DB reload
if cache.Redis != nil {
cache.Redis.Del(context.Background(), cache.PrefixedKey("system_configs"))
}
// Reload config
c.ReloadConfig(context.Background())
status := c.Status()
if status.MaxSizeMB != 250 {
t.Errorf("expected MaxSizeMB to be 250, got %d", status.MaxSizeMB)
}
if status.TTLMinutes != 120 {
t.Errorf("expected TTLMinutes to be 120, got %d", status.TTLMinutes)
}
if status.LRUEnabled != false {
t.Errorf("expected LRUEnabled to be false, got %v", status.LRUEnabled)
}
}