(new): rich message support
Golang lint / lint (pull_request) Successful in 1m20s
Golang lint / lint (push) Successful in 4m8s

(fix): runtime reliability
(tests): regression coverage
(doc): v1.1 release notes
This commit is contained in:
2026-08-12 16:34:44 +03:00
parent 48ddf66540
commit f03a081ed6
83 changed files with 6122 additions and 1925 deletions
+21
View File
@@ -5,6 +5,8 @@ import (
"errors"
"testing"
"time"
"golang.org/x/time/rate"
)
func TestRateLimiterCheckDropOverflowHonorsGlobalLock(t *testing.T) {
@@ -28,6 +30,25 @@ func TestRateLimiterChatLocksAreScopedPerChat(t *testing.T) {
}
}
func TestRateLimiterRejectedChatDoesNotConsumeGlobalCapacity(t *testing.T) {
rl := NewRateLimiter()
rl.SetGlobalRate(1)
if !rl.Allow(42) {
t.Fatal("expected initial request for chat 42 to succeed")
}
rl.globalMu.Lock()
rl.globalLimiter = rate.NewLimiter(1, 1)
rl.globalMu.Unlock()
if rl.Allow(42) {
t.Fatal("expected exhausted chat limiter to reject the request")
}
if !rl.Allow(7) {
t.Fatal("expected rejected chat request not to consume global capacity")
}
}
func TestRateLimiterGlobalWaitRespectsContextCancellation(t *testing.T) {
rl := NewRateLimiter()
rl.SetGlobalLock(1)