@@ -432,6 +432,8 @@ func TestTokenCache_Get_Expired(t *testing.T) {
432432 found , authenticated , _ = cache .Get (token )
433433 assert .False (t , found )
434434 assert .False (t , authenticated )
435+ // Expired entry should be evicted from cache, not just hidden
436+ assert .Equal (t , 0 , cache .Size (), "Expired entry should be evicted from cache" )
435437}
436438
437439func TestTokenCache_UpdateExisting (t * testing.T ) {
@@ -486,18 +488,19 @@ func TestTokenCache_LRUBehavior(t *testing.T) {
486488 cache .Set (token , true , "user" + string (rune ('0' + i )))
487489 }
488490
489- // Access first entry (Get doesn't update LRU, only Set does )
491+ // Access first entry (Get promotes to front of LRU list )
490492 cache .Get ("token0" )
491493
492- // Add new entry - should evict oldest (token0, since Get doesn't update LRU)
494+ // Add new entry - should evict token1 (now the least recently used
495+ // because token0 was promoted by Get)
493496 cache .Set ("token3" , true , "user3" )
494497
495- // token0 should be evicted (oldest in LRU list )
498+ // token0 should still be present (was promoted by Get )
496499 found , _ , _ := cache .Get ("token0" )
497- assert .False (t , found )
498- // token1 should be present
499- found , _ , _ = cache .Get ("token1" )
500500 assert .True (t , found )
501+ // token1 should be evicted (least recently used)
502+ found , _ , _ = cache .Get ("token1" )
503+ assert .False (t , found )
501504 // token2 should be present
502505 found , _ , _ = cache .Get ("token2" )
503506 assert .True (t , found )
0 commit comments