mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-13 08:05:19 +09:00
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 <maximbel2003@gmail.com>
This commit is contained in:
1 parent
f48a94de6d
commit
dff23f76e0
1 file changed
+4
-2
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user