-
This commit is contained in:
@ -12,48 +12,6 @@ import (
|
||||
"github.com/kms/api-key-service/internal/cache"
|
||||
)
|
||||
|
||||
// MockConfig implements ConfigProvider for testing
|
||||
type MockConfig struct {
|
||||
values map[string]string
|
||||
}
|
||||
|
||||
func NewMockConfig() *MockConfig {
|
||||
return &MockConfig{
|
||||
values: map[string]string{
|
||||
"CACHE_ENABLED": "true",
|
||||
"CACHE_TTL": "1h",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MockConfig) GetString(key string) string {
|
||||
return m.values[key]
|
||||
}
|
||||
|
||||
func (m *MockConfig) GetInt(key string) int { return 0 }
|
||||
func (m *MockConfig) GetBool(key string) bool {
|
||||
if key == "CACHE_ENABLED" {
|
||||
return m.values[key] == "true"
|
||||
}
|
||||
return false
|
||||
}
|
||||
func (m *MockConfig) GetDuration(key string) time.Duration {
|
||||
if key == "CACHE_TTL" {
|
||||
if d, err := time.ParseDuration(m.values[key]); err == nil {
|
||||
return d
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
func (m *MockConfig) GetStringSlice(key string) []string { return nil }
|
||||
func (m *MockConfig) IsSet(key string) bool { return m.values[key] != "" }
|
||||
func (m *MockConfig) Validate() error { return nil }
|
||||
func (m *MockConfig) GetDatabaseDSN() string { return "" }
|
||||
func (m *MockConfig) GetServerAddress() string { return "" }
|
||||
func (m *MockConfig) GetMetricsAddress() string { return "" }
|
||||
func (m *MockConfig) GetJWTSecret() string { return m.GetString("JWT_SECRET") }
|
||||
func (m *MockConfig) IsDevelopment() bool { return true }
|
||||
func (m *MockConfig) IsProduction() bool { return false }
|
||||
|
||||
func TestMemoryCache_SetAndGet(t *testing.T) {
|
||||
config := NewMockConfig()
|
||||
@ -315,12 +273,9 @@ func TestCacheKeyPrefixes(t *testing.T) {
|
||||
|
||||
func TestCacheManager_ConfigMethods(t *testing.T) {
|
||||
// Create mock config with cache settings
|
||||
config := &MockConfig{
|
||||
values: map[string]string{
|
||||
"CACHE_ENABLED": "true",
|
||||
"CACHE_TTL": "1h",
|
||||
},
|
||||
}
|
||||
config := NewMockConfig()
|
||||
config.values["CACHE_ENABLED"] = "true"
|
||||
config.values["CACHE_TTL"] = "1h"
|
||||
logger := zap.NewNop()
|
||||
cacheManager := cache.NewCacheManager(config, logger)
|
||||
defer cacheManager.Close()
|
||||
|
||||
Reference in New Issue
Block a user