From dff23f76e0d421ac0e79f25c056ba787ec081e1e Mon Sep 17 00:00:00 2001 From: ZverGuy Date: Tue, 10 Nov 2026 00:45:01 +0700 Subject: [PATCH] test(observability-proxy): spend the rate burst in a loop Calling allowed twice in one condition reads as a duplicated expression to staticcheck, which cannot see that each call takes a token. Assisted-by: LLM Signed-off-by: ZverGuy --- internal/observabilityproxy/limits_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/observabilityproxy/limits_test.go b/internal/observabilityproxy/limits_test.go index 706ed71c7..d7f4c76f4 100644 --- a/internal/observabilityproxy/limits_test.go +++ b/internal/observabilityproxy/limits_test.go @@ -77,8 +77,10 @@ func TestLimiterRate(t *testing.T) { now := time.Unix(1000, 0) l := newLimiter(LimiterConfig{RatePerUser: 2, RateBurst: 2}) l.now = func() time.Time { return now } - if !allowed(l, "alice") || !allowed(l, "alice") { - t.Fatal("burst refused") + for i := range 2 { + if !allowed(l, "alice") { + t.Fatalf("burst request %d refused", i+1) + } } if wait, ok := l.allowRate("alice"); ok || wait != 500*time.Millisecond { t.Fatalf("request over the burst: admitted %v, wait %s, want refused with 500ms", ok, wait)