mirror of
https://github.com/samber/lo.git
synced 2025-09-26 20:11:13 +08:00
fix: fix randomly failing test
This commit is contained in:
@@ -544,7 +544,7 @@ func TestNewThrottleWithCount(t *testing.T) {
|
|||||||
}
|
}
|
||||||
is.Equal(3, callCount)
|
is.Equal(3, callCount)
|
||||||
|
|
||||||
time.Sleep(11 * time.Millisecond)
|
time.Sleep(15 * time.Millisecond)
|
||||||
|
|
||||||
for i := 0; i < 20; i++ {
|
for i := 0; i < 20; i++ {
|
||||||
th()
|
th()
|
||||||
@@ -572,7 +572,7 @@ func TestNewThrottleBy(t *testing.T) {
|
|||||||
callCountB++
|
callCountB++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
th, reset := NewThrottleBy[string](10*time.Millisecond, f1)
|
th, reset := NewThrottleBy(10*time.Millisecond, f1)
|
||||||
|
|
||||||
is.Equal(0, callCountA)
|
is.Equal(0, callCountA)
|
||||||
is.Equal(0, callCountB)
|
is.Equal(0, callCountB)
|
||||||
@@ -604,6 +604,7 @@ func TestNewThrottleBy(t *testing.T) {
|
|||||||
func TestNewThrottleByWithCount(t *testing.T) {
|
func TestNewThrottleByWithCount(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
is := assert.New(t)
|
is := assert.New(t)
|
||||||
|
|
||||||
callCountA := 0
|
callCountA := 0
|
||||||
callCountB := 0
|
callCountB := 0
|
||||||
f1 := func(key string) {
|
f1 := func(key string) {
|
||||||
@@ -623,7 +624,7 @@ func TestNewThrottleByWithCount(t *testing.T) {
|
|||||||
is.Equal(3, callCountA)
|
is.Equal(3, callCountA)
|
||||||
is.Equal(3, callCountB)
|
is.Equal(3, callCountB)
|
||||||
|
|
||||||
time.Sleep(11 * time.Millisecond)
|
time.Sleep(15 * time.Millisecond)
|
||||||
|
|
||||||
for i := 0; i < 20; i++ {
|
for i := 0; i < 20; i++ {
|
||||||
th("a")
|
th("a")
|
||||||
|
Reference in New Issue
Block a user