@@ -133,36 +133,6 @@ development:
133133 Expect (err ).NotTo (HaveOccurred ())
134134 })
135135
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-
166136 It ("should create Milvus cache backend successfully with valid config" , func () {
167137 config := cache.CacheConfig {
168138 BackendType : cache .MilvusCacheType ,
@@ -221,6 +191,25 @@ development:
221191 Expect (backend ).To (BeNil ())
222192 })
223193 })
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+
224213 })
225214
226215 Describe ("ValidateCacheConfig" , func () {
@@ -319,6 +308,20 @@ development:
319308 Expect (err .Error ()).To (ContainSubstring ("backend_config_path is required for Milvus" ))
320309 })
321310
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+
322325 It ("should validate edge case values" , func () {
323326 config := cache.CacheConfig {
324327 BackendType : cache .InMemoryCacheType ,
0 commit comments