@@ -133,36 +133,6 @@ development:
133
133
Expect (err ).NotTo (HaveOccurred ())
134
134
})
135
135
136
- It ("should return error when backend_config_path is missing" , func () {
137
- config := cache.CacheConfig {
138
- BackendType : cache .MilvusCacheType ,
139
- Enabled : true ,
140
- SimilarityThreshold : 0.8 ,
141
- TTLSeconds : 3600 ,
142
- // BackendConfigPath is missing
143
- }
144
-
145
- backend , err := cache .NewCacheBackend (config )
146
- Expect (err ).To (HaveOccurred ())
147
- Expect (err .Error ()).To (ContainSubstring ("backend_config_path is required" ))
148
- Expect (backend ).To (BeNil ())
149
- })
150
-
151
- It ("should return error when backend_config_path file doesn't exist" , func () {
152
- config := cache.CacheConfig {
153
- BackendType : cache .MilvusCacheType ,
154
- Enabled : true ,
155
- SimilarityThreshold : 0.8 ,
156
- TTLSeconds : 3600 ,
157
- BackendConfigPath : "/nonexistent/milvus.yaml" ,
158
- }
159
-
160
- backend , err := cache .NewCacheBackend (config )
161
- Expect (err ).To (HaveOccurred ())
162
- Expect (err .Error ()).To (ContainSubstring ("config file not found" ))
163
- Expect (backend ).To (BeNil ())
164
- })
165
-
166
136
It ("should create Milvus cache backend successfully with valid config" , func () {
167
137
config := cache.CacheConfig {
168
138
BackendType : cache .MilvusCacheType ,
@@ -221,6 +191,25 @@ development:
221
191
Expect (backend ).To (BeNil ())
222
192
})
223
193
})
194
+
195
+ Context ("with invalid config but valid backend type" , func () {
196
+ It ("should return error due to validation when config has invalid values" , func () {
197
+ config := cache.CacheConfig {
198
+ BackendType : cache .InMemoryCacheType , // valid backend type
199
+ Enabled : true ,
200
+ SimilarityThreshold : - 0.8 , // invalid
201
+ MaxEntries : 10 ,
202
+ TTLSeconds : - 1 , // invalid
203
+ }
204
+
205
+ backend , err := cache .NewCacheBackend (config )
206
+
207
+ Expect (err ).To (HaveOccurred ())
208
+ Expect (err .Error ()).To (ContainSubstring ("invalid cache config" )) // ensure from config validation
209
+ Expect (backend ).To (BeNil ())
210
+ })
211
+ })
212
+
224
213
})
225
214
226
215
Describe ("ValidateCacheConfig" , func () {
@@ -319,6 +308,20 @@ development:
319
308
Expect (err .Error ()).To (ContainSubstring ("backend_config_path is required for Milvus" ))
320
309
})
321
310
311
+ It ("should return error when Milvus backend_config_path file doesn't exist" , func () {
312
+ config := cache.CacheConfig {
313
+ BackendType : cache .MilvusCacheType ,
314
+ Enabled : true ,
315
+ SimilarityThreshold : 0.8 ,
316
+ TTLSeconds : 3600 ,
317
+ BackendConfigPath : "/nonexistent/milvus.yaml" ,
318
+ }
319
+
320
+ err := cache .ValidateCacheConfig (config )
321
+ Expect (err ).To (HaveOccurred ())
322
+ Expect (err .Error ()).To (ContainSubstring ("config file not found" ))
323
+ })
324
+
322
325
It ("should validate edge case values" , func () {
323
326
config := cache.CacheConfig {
324
327
BackendType : cache .InMemoryCacheType ,
0 commit comments