Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests in parallel. #98

Merged
merged 1 commit into from
Jul 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ratelimit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func (r *runnerImpl) goWait(fn func()) {
}

func TestUnlimited(t *testing.T) {
t.Parallel()
now := time.Now()
rl := NewUnlimited()
for i := 0; i < 1000; i++ {
Expand All @@ -152,6 +153,7 @@ func TestUnlimited(t *testing.T) {
}

func TestRateLimiter(t *testing.T) {
t.Parallel()
runTest(t, func(r testRunner) {
rl := r.createLimiter(100, WithoutSlack)

Expand All @@ -168,6 +170,7 @@ func TestRateLimiter(t *testing.T) {
}

func TestDelayedRateLimiter(t *testing.T) {
t.Parallel()
runTest(t, func(r testRunner) {
slow := r.createLimiter(10, WithoutSlack)
fast := r.createLimiter(100, WithoutSlack)
Expand All @@ -186,6 +189,7 @@ func TestDelayedRateLimiter(t *testing.T) {
}

func TestPer(t *testing.T) {
t.Parallel()
runTest(t, func(r testRunner) {
rl := r.createLimiter(7, WithoutSlack, Per(time.Minute))

Expand All @@ -199,6 +203,7 @@ func TestPer(t *testing.T) {
}

func TestSlack(t *testing.T) {
t.Parallel()
// To simulate slack, we combine two limiters.
// - First, we start a single goroutine with both of them,
// during this time the slow limiter will dominate,
Expand Down