File tree Expand file tree Collapse file tree 1 file changed +12
-14
lines changed
Expand file tree Collapse file tree 1 file changed +12
-14
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments