Fix test condition for ratelimit
package ratelimit
import (
+ "context"
"fmt"
"os"
"testing"
@@ -18,7 +19,7 @@ func TestRateLimit(t *testing.T) {
rateLimiter := NewRateLimiter(os.Getenv("REDIS_URL"), fmt.Sprintf("worker-test-rl-%d", os.Getpid()))
- ok, err := rateLimiter.RateLimit(ctx, "slow", 2, time.Hour)
+ ok, err := rateLimiter.RateLimit(context.TODO(), "slow", 2, time.Hour)
if err != nil {
t.Fatalf("rate limiter error: %v", err)
}
@@ -26,7 +27,7 @@ func TestRateLimit(t *testing.T) {
t.Fatal("expected to not get rate limited, but was limited")
}
- ok, err = rateLimiter.RateLimit(ctx, "slow", 2, time.Hour)
+ ok, err = rateLimiter.RateLimit(context.TODO(), "slow", 2, time.Hour)
if err != nil {
t.Fatalf("rate limiter error: %v", err)
}
@@ -34,7 +35,7 @@ func TestRateLimit(t *testing.T) {
t.Fatal("expected to not get rate limited, but was limited")
}
- ok, err = rateLimiter.RateLimit(ctx, "slow", 2, time.Hour)
+ ok, err = rateLimiter.RateLimit("slow", 2, time.Hour)
if err != nil {
t.Fatalf("rate limiter error: %v", err)
}
