(new): expand runtime APIs
(fix): harden concurrent lifecycle (tests): add regression coverage (doc): update v1.2 guidance
This commit is contained in:
@@ -189,3 +189,18 @@ func TestRateLimiterCleanupEvictsIdleChats(t *testing.T) {
|
||||
t.Fatal("expected future chat 11 lock to remain")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRateLimiterCleanupPreservesAcquiredLimiter(t *testing.T) {
|
||||
rl := NewRateLimiter()
|
||||
limiter, release := rl.acquireChatLimiter(42)
|
||||
|
||||
rl.chatMu.Lock()
|
||||
rl.chatLastSeen[42] = time.Now().Add(-time.Hour)
|
||||
rl.chatMu.Unlock()
|
||||
rl.Cleanup(time.Minute)
|
||||
|
||||
if got := rl.getChatLimiter(42); got != limiter {
|
||||
t.Fatal("Cleanup replaced a limiter while it was acquired")
|
||||
}
|
||||
release()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user