@@ -121,7 +121,7 @@ func TestCacheModule(t *testing.T) {
121121
122122 // Test services provided
123123 services := module .(* CacheModule ).ProvidesServices ()
124- assert .Equal (t , 1 , len ( services ) )
124+ assert .Len (t , services , 1 )
125125 assert .Equal (t , ServiceName , services [0 ].Name )
126126}
127127
@@ -146,14 +146,14 @@ func TestMemoryCacheOperations(t *testing.T) {
146146
147147 // Test basic operations
148148 err = module .Set (ctx , "test-key" , "test-value" , time .Minute )
149- assert .NoError (t , err )
149+ require .NoError (t , err )
150150
151151 value , found := module .Get (ctx , "test-key" )
152152 assert .True (t , found )
153153 assert .Equal (t , "test-value" , value )
154154
155155 err = module .Delete (ctx , "test-key" )
156- assert .NoError (t , err )
156+ require .NoError (t , err )
157157
158158 _ , found = module .Get (ctx , "test-key" )
159159 assert .False (t , found )
@@ -166,16 +166,16 @@ func TestMemoryCacheOperations(t *testing.T) {
166166 }
167167
168168 err = module .SetMulti (ctx , items , time .Minute )
169- assert .NoError (t , err )
169+ require .NoError (t , err )
170170
171171 results , err := module .GetMulti (ctx , []string {"key1" , "key2" , "key4" })
172- assert .NoError (t , err )
172+ require .NoError (t , err )
173173 assert .Equal (t , "value1" , results ["key1" ])
174174 assert .Equal (t , "value2" , results ["key2" ])
175175 assert .NotContains (t , results , "key4" )
176176
177177 err = module .Flush (ctx )
178- assert .NoError (t , err )
178+ require .NoError (t , err )
179179
180180 _ , found = module .Get (ctx , "key1" )
181181 assert .False (t , found )
@@ -211,7 +211,7 @@ func TestExpiration(t *testing.T) {
211211
212212 // Set with short TTL
213213 err = module .Set (ctx , "expires-quickly" , "value" , time .Second )
214- assert .NoError (t , err )
214+ require .NoError (t , err )
215215
216216 // Verify it exists
217217 _ , found := module .Get (ctx , "expires-quickly" )
@@ -300,7 +300,7 @@ func TestRedisOperationsWithMockBehavior(t *testing.T) {
300300
301301 // Test close without connection
302302 err = cache .Close (ctx )
303- assert .NoError (t , err )
303+ require .NoError (t , err )
304304}
305305
306306// TestRedisConfigurationEdgeCases tests edge cases in Redis configuration
@@ -342,16 +342,16 @@ func TestRedisMultiOperationsEmptyInputs(t *testing.T) {
342342
343343 // Test GetMulti with empty keys - should return empty map (no connection needed)
344344 results , err := cache .GetMulti (ctx , []string {})
345- assert .NoError (t , err )
345+ require .NoError (t , err )
346346 assert .Equal (t , map [string ]interface {}{}, results )
347347
348348 // Test SetMulti with empty items - should succeed (no connection needed)
349349 err = cache .SetMulti (ctx , map [string ]interface {}{}, time .Minute )
350- assert .NoError (t , err )
350+ require .NoError (t , err )
351351
352352 // Test DeleteMulti with empty keys - should succeed (no connection needed)
353353 err = cache .DeleteMulti (ctx , []string {})
354- assert .NoError (t , err )
354+ require .NoError (t , err )
355355}
356356
357357// TestRedisConnectWithPassword tests connection configuration with password
@@ -373,11 +373,11 @@ func TestRedisConnectWithPassword(t *testing.T) {
373373 // Test connection with password and different DB - this will fail since no Redis server
374374 // but will exercise the connection configuration code paths
375375 err := cache .Connect (ctx )
376- assert .Error (t , err ) // Expected to fail without Redis server
376+ require .Error (t , err ) // Expected to fail without Redis server
377377
378378 // Test Close when client is nil initially
379379 err = cache .Close (ctx )
380- assert .NoError (t , err )
380+ require .NoError (t , err )
381381}
382382
383383// TestRedisJSONMarshaling tests JSON marshaling error scenarios
@@ -445,15 +445,15 @@ func TestRedisFullOperations(t *testing.T) {
445445
446446 // Test Set and Get
447447 err = cache .Set (ctx , "test-key" , "test-value" , time .Minute )
448- assert .NoError (t , err )
448+ require .NoError (t , err )
449449
450450 value , found := cache .Get (ctx , "test-key" )
451451 assert .True (t , found )
452452 assert .Equal (t , "test-value" , value )
453453
454454 // Test Delete
455455 err = cache .Delete (ctx , "test-key" )
456- assert .NoError (t , err )
456+ require .NoError (t , err )
457457
458458 _ , found = cache .Get (ctx , "test-key" )
459459 assert .False (t , found )
@@ -466,18 +466,18 @@ func TestRedisFullOperations(t *testing.T) {
466466 }
467467
468468 err = cache .SetMulti (ctx , items , time .Minute )
469- assert .NoError (t , err )
469+ require .NoError (t , err )
470470
471471 results , err := cache .GetMulti (ctx , []string {"key1" , "key2" , "key3" , "nonexistent" })
472- assert .NoError (t , err )
472+ require .NoError (t , err )
473473 assert .Equal (t , "value1" , results ["key1" ])
474- assert .Equal (t , float64 (42 ), results ["key2" ]) // JSON unmarshaling returns numbers as float64
474+ assert .InDelta (t , float64 (42 ), results ["key2" ], 0.01 ) // JSON unmarshaling returns numbers as float64
475475 assert .Equal (t , map [string ]interface {}{"nested" : "value" }, results ["key3" ])
476476 assert .NotContains (t , results , "nonexistent" )
477477
478478 // Test DeleteMulti
479479 err = cache .DeleteMulti (ctx , []string {"key1" , "key2" })
480- assert .NoError (t , err )
480+ require .NoError (t , err )
481481
482482 // Verify deletions
483483 _ , found = cache .Get (ctx , "key1" )
@@ -490,14 +490,14 @@ func TestRedisFullOperations(t *testing.T) {
490490
491491 // Test Flush
492492 err = cache .Flush (ctx )
493- assert .NoError (t , err )
493+ require .NoError (t , err )
494494
495495 _ , found = cache .Get (ctx , "key3" )
496496 assert .False (t , found )
497497
498498 // Test Close
499499 err = cache .Close (ctx )
500- assert .NoError (t , err )
500+ require .NoError (t , err )
501501}
502502
503503// TestRedisGetJSONUnmarshalError tests JSON unmarshaling errors in Get
@@ -526,7 +526,7 @@ func TestRedisGetJSONUnmarshalError(t *testing.T) {
526526 defer cache .Close (ctx )
527527
528528 // Manually insert invalid JSON into Redis
529- s .Set ("invalid-json" , "this is not valid JSON {" )
529+ _ = s .Set ("invalid-json" , "this is not valid JSON {" )
530530
531531 // Try to get the invalid JSON value
532532 value , found := cache .Get (ctx , "invalid-json" )
@@ -567,7 +567,7 @@ func TestRedisGetWithServerError(t *testing.T) {
567567
568568 // Try GetMulti when server is down
569569 results , err := cache .GetMulti (ctx , []string {"key1" , "key2" })
570- assert .Error (t , err )
570+ require .Error (t , err )
571571 assert .Nil (t , results )
572572
573573 // Close cache
0 commit comments