initial Go port of streamrip

This commit is contained in:
2026-04-19 21:11:38 +02:00
commit 97e8b758b3
32 changed files with 7008 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
package ratelimit
import (
"context"
"testing"
"time"
)
func TestLimiterDisabled(t *testing.T) {
l := New(-1)
if err := l.Wait(context.Background()); err != nil {
t.Fatalf("Wait() error = %v", err)
}
}
func TestLimiterContextCancel(t *testing.T) {
l := New(1)
if err := l.Wait(context.Background()); err != nil {
t.Fatalf("first Wait() error = %v", err)
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Millisecond)
defer cancel()
if err := l.Wait(ctx); err == nil {
t.Fatalf("expected context error")
}
}