Skip to content

Commit fdd8865

Browse files
Lee,Minjeasamber
authored andcommitted
fix: test case fixed
1 parent 27638ea commit fdd8865

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

retry_test.go

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -509,25 +509,23 @@ func TestNewThrottle(t *testing.T) {
509509
th, reset := NewThrottle(10*time.Millisecond, f1)
510510

511511
is.Equal(0, callCount)
512-
for i := 0; i < 9; i++ {
513-
var wg sync.WaitGroup
514-
for j := 0; j < 100; j++ {
515-
wg.Add(1)
516-
go func() {
517-
defer wg.Done()
518-
th()
519-
}()
520-
}
521-
wg.Wait()
522-
time.Sleep(3 * time.Millisecond)
512+
for j := 0; j < 100; j++ {
513+
th()
523514
}
524-
// 35 ms passed
525-
is.Equal(3, callCount)
515+
is.Equal(1, callCount)
516+
517+
time.Sleep(15 * time.Millisecond)
518+
519+
for j := 0; j < 100; j++ {
520+
th()
521+
}
522+
523+
is.Equal(2, callCount)
526524

527525
// reset counter
528526
reset()
529527
th()
530-
is.Equal(4, callCount)
528+
is.Equal(3, callCount)
531529

532530
}
533531

0 commit comments

Comments
 (0)