Skip to content

Commit

Permalink
fix: test case fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee,Minjea authored and samber committed Jan 26, 2025
1 parent 27638ea commit fdd8865
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,25 +509,23 @@ func TestNewThrottle(t *testing.T) {
th, reset := NewThrottle(10*time.Millisecond, f1)

is.Equal(0, callCount)
for i := 0; i < 9; i++ {
var wg sync.WaitGroup
for j := 0; j < 100; j++ {
wg.Add(1)
go func() {
defer wg.Done()
th()
}()
}
wg.Wait()
time.Sleep(3 * time.Millisecond)
for j := 0; j < 100; j++ {
th()
}
// 35 ms passed
is.Equal(3, callCount)
is.Equal(1, callCount)

time.Sleep(15 * time.Millisecond)

for j := 0; j < 100; j++ {
th()
}

is.Equal(2, callCount)

// reset counter
reset()
th()
is.Equal(4, callCount)
is.Equal(3, callCount)

}

Expand Down

0 comments on commit fdd8865

Please sign in to comment.