@@ -86,6 +86,7 @@ func (m *mockPersister[K, V]) Delete(ctx context.Context, key K) error {
8686 return nil
8787}
8888
89+ //nolint:gocritic // Channel returns are clearer without named results
8990func (m * mockPersister [K , V ]) LoadRecent (ctx context.Context , limit int ) (<- chan Entry [K , V ], <- chan error ) {
9091 entryCh := make (chan Entry [K , V ], 10 )
9192 errCh := make (chan error , 1 )
@@ -166,7 +167,7 @@ func TestCache_WithPersistence(t *testing.T) {
166167 if err != nil {
167168 t .Fatalf ("New: %v" , err )
168169 }
169- defer func () { _ = cache .Close () }()
170+ defer func () { _ = cache .Close () }() //nolint:errcheck // Test cleanup
170171
171172 // Set should persist
172173 if err := cache .Set (ctx , "key1" , 42 , 0 ); err != nil {
@@ -202,13 +203,13 @@ func TestCache_GetFromPersistence(t *testing.T) {
202203 persister := newMockPersister [string , int ]()
203204
204205 // Pre-populate persistence
205- _ = persister .Store (ctx , "key1" , 42 , time.Time {})
206+ _ = persister .Store (ctx , "key1" , 42 , time.Time {}) //nolint:errcheck // Test fixture
206207
207208 cache , err := New [string , int ](ctx , WithPersistence (persister ))
208209 if err != nil {
209210 t .Fatalf ("New: %v" , err )
210211 }
211- defer func () { _ = cache .Close () }()
212+ defer func () { _ = cache .Close () }() //nolint:errcheck // Test cleanup
212213
213214 // Get should load from persistence
214215 val , found , err := cache .Get (ctx , "key1" )
@@ -228,13 +229,13 @@ func TestCache_GetFromPersistenceExpired(t *testing.T) {
228229 persister := newMockPersister [string , int ]()
229230
230231 // Pre-populate with expired entry
231- _ = persister .Store (ctx , "key1" , 42 , time .Now ().Add (- 1 * time .Hour ))
232+ _ = persister .Store (ctx , "key1" , 42 , time .Now ().Add (- 1 * time .Hour )) //nolint:errcheck // Test fixture
232233
233234 cache , err := New [string , int ](ctx , WithPersistence (persister ))
234235 if err != nil {
235236 t .Fatalf ("New: %v" , err )
236237 }
237- defer func () { _ = cache .Close () }()
238+ defer func () { _ = cache .Close () }() //nolint:errcheck // Test cleanup
238239
239240 // Get should return not found for expired entry
240241 _ , found , err := cache .Get (ctx , "key1" )
@@ -252,7 +253,7 @@ func TestCache_WithWarmup(t *testing.T) {
252253
253254 // Pre-populate persistence with 10 items
254255 for i := range 10 {
255- _ = persister .Store (ctx , fmt .Sprintf ("key%d" , i ), i , time.Time {})
256+ _ = persister .Store (ctx , fmt .Sprintf ("key%d" , i ), i , time.Time {}) //nolint:errcheck // Test fixture
256257 }
257258
258259 // Create cache with warmup limit of 5
@@ -262,7 +263,7 @@ func TestCache_WithWarmup(t *testing.T) {
262263 if err != nil {
263264 t .Fatalf ("New: %v" , err )
264265 }
265- defer func () { _ = cache .Close () }()
266+ defer func () { _ = cache .Close () }() //nolint:errcheck // Test cleanup
266267
267268 // Give warmup goroutine time to complete
268269 time .Sleep (100 * time .Millisecond )
@@ -282,9 +283,9 @@ func TestCache_WithCleanupOnStartup(t *testing.T) {
282283
283284 // Pre-populate with expired entries
284285 past := time .Now ().Add (- 2 * time .Hour )
285- _ = persister .Store (ctx , "expired1" , 1 , past )
286- _ = persister .Store (ctx , "expired2" , 2 , past )
287- _ = persister .Store (ctx , "valid" , 3 , time.Time {})
286+ _ = persister .Store (ctx , "expired1" , 1 , past ) //nolint:errcheck // Test fixture
287+ _ = persister .Store (ctx , "expired2" , 2 , past ) //nolint:errcheck // Test fixture
288+ _ = persister .Store (ctx , "valid" , 3 , time.Time {}) //nolint:errcheck // Test fixture
288289
289290 // Create cache with cleanup
290291 cache , err := New [string , int ](ctx ,
@@ -293,7 +294,7 @@ func TestCache_WithCleanupOnStartup(t *testing.T) {
293294 if err != nil {
294295 t .Fatalf ("New: %v" , err )
295296 }
296- defer func () { _ = cache .Close () }()
297+ defer func () { _ = cache .Close () }() //nolint:errcheck // Test cleanup
297298
298299 // Expired entries should be cleaned up
299300 _ , _ , found , err := persister .Load (ctx , "expired1" )
@@ -322,7 +323,7 @@ func TestCache_SetAsyncWithPersistence(t *testing.T) {
322323 if err != nil {
323324 t .Fatalf ("New: %v" , err )
324325 }
325- defer func () { _ = cache .Close () }()
326+ defer func () { _ = cache .Close () }() //nolint:errcheck // Test cleanup
326327
327328 // SetAsync should not block but value should be available immediately
328329 if err := cache .SetAsync (ctx , "key1" , 42 , 0 ); err != nil {
@@ -378,7 +379,7 @@ func TestCache_PersistenceErrors(t *testing.T) {
378379 if err != nil {
379380 t .Fatalf ("New: %v" , err )
380381 }
381- defer func () { _ = cache .Close () }()
382+ defer func () { _ = cache .Close () }() //nolint:errcheck // Test cleanup
382383
383384 // Set returns error when persistence fails (by design)
384385 // Value is still in memory, but error is returned to caller
@@ -434,7 +435,7 @@ func TestCache_Delete_Errors(t *testing.T) {
434435 if err != nil {
435436 t .Fatalf ("New: %v" , err )
436437 }
437- defer func () { _ = cache .Close () }()
438+ defer func () { _ = cache .Close () }() //nolint:errcheck // Test cleanup
438439
439440 // Store a value (with failSet = false)
440441 persister .failSet = false
@@ -483,7 +484,7 @@ func TestCache_Get_InvalidKey(t *testing.T) {
483484 if err != nil {
484485 t .Fatalf ("New: %v" , err )
485486 }
486- defer func () { _ = cache .Close () }()
487+ defer func () { _ = cache .Close () }() //nolint:errcheck // Test cleanup
487488
488489 // Get with empty key (invalid)
489490 _ , found , err := cache .Get (ctx , "" )
@@ -503,10 +504,10 @@ func TestCache_Get_PersistenceLoadError(t *testing.T) {
503504 if err != nil {
504505 t .Fatalf ("New: %v" , err )
505506 }
506- defer func () { _ = cache .Close () }()
507+ defer func () { _ = cache .Close () }() //nolint:errcheck // Test cleanup
507508
508509 // Pre-populate persistence (not in memory)
509- _ = persister .Store (ctx , "key1" , 42 , time.Time {})
510+ _ = persister .Store (ctx , "key1" , 42 , time.Time {}) //nolint:errcheck // Test fixture
510511
511512 // Make persistence Load fail
512513 persister .failGet = true
@@ -548,7 +549,7 @@ func TestCache_GhostQueue(t *testing.T) {
548549 if err != nil {
549550 t .Fatalf ("New: %v" , err )
550551 }
551- defer func () { _ = cache .Close () }()
552+ defer func () { _ = cache .Close () }() //nolint:errcheck // Test cleanup
552553
553554 // Fill small queue (10% of 10 = 1)
554555 // Insert items to trigger ghost queue
@@ -560,7 +561,7 @@ func TestCache_GhostQueue(t *testing.T) {
560561
561562 // Access some items to create hot items
562563 for i := range 5 {
563- _ , _ , _ = cache .Get (ctx , fmt .Sprintf ("key%d" , i ))
564+ _ , _ , _ = cache .Get (ctx , fmt .Sprintf ("key%d" , i )) //nolint:errcheck // Exercising code path
564565 }
565566
566567 // Insert more to trigger evictions from small queue to ghost queue
@@ -582,7 +583,7 @@ func TestCache_MainQueueEviction(t *testing.T) {
582583 if err != nil {
583584 t .Fatalf ("New: %v" , err )
584585 }
585- defer func () { _ = cache .Close () }()
586+ defer func () { _ = cache .Close () }() //nolint:errcheck // Test cleanup
586587
587588 // Insert and access items to get them into Main queue
588589 for i := range 15 {
@@ -591,7 +592,7 @@ func TestCache_MainQueueEviction(t *testing.T) {
591592 t .Fatalf ("Set: %v" , err )
592593 }
593594 // Access to promote to Main
594- _ , _ , _ = cache .Get (ctx , key )
595+ _ , _ , _ = cache .Get (ctx , key ) //nolint:errcheck // Exercising code path
595596 }
596597
597598 // Insert more items to trigger eviction from Main queue
@@ -600,7 +601,7 @@ func TestCache_MainQueueEviction(t *testing.T) {
600601 if err := cache .Set (ctx , key , i + 15 , 0 ); err != nil {
601602 t .Fatalf ("Set: %v" , err )
602603 }
603- _ , _ , _ = cache .Get (ctx , key )
604+ _ , _ , _ = cache .Get (ctx , key ) //nolint:errcheck // Exercising code path
604605 }
605606
606607 // Verify cache is at capacity
@@ -616,13 +617,13 @@ func TestCache_CleanupExpiredEntries(t *testing.T) {
616617 if err != nil {
617618 t .Fatalf ("New: %v" , err )
618619 }
619- defer func () { _ = cache .Close () }()
620+ defer func () { _ = cache .Close () }() //nolint:errcheck // Test cleanup
620621
621622 // Store items with expiry
622623 past := time .Now ().Add (- 1 * time .Hour )
623- _ = cache .Set (ctx , "expired1" , 1 , - 1 * time .Hour ) // Already expired
624- _ = cache .Set (ctx , "expired2" , 2 , - 1 * time .Hour )
625- _ = cache .Set (ctx , "valid" , 3 , 1 * time .Hour )
624+ _ = cache .Set (ctx , "expired1" , 1 , - 1 * time .Hour ) //nolint:errcheck // Test fixture
625+ _ = cache .Set (ctx , "expired2" , 2 , - 1 * time .Hour ) //nolint:errcheck // Test fixture
626+ _ = cache .Set (ctx , "valid" , 3 , 1 * time .Hour ) //nolint:errcheck // Test fixture
626627
627628 // Manually set expiry to past for testing
628629 if err := cache .Set (ctx , "test-expired" , 99 , 0 ); err != nil {
0 commit comments