mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
32 lines
422 B
Go
32 lines
422 B
Go
package main
|
|
|
|
import (
|
|
"io"
|
|
"sync"
|
|
"testing"
|
|
)
|
|
|
|
func TestLimiter(t *testing.T) {
|
|
wg := new(sync.WaitGroup)
|
|
quit := make(chan int)
|
|
|
|
input := NewTestInput()
|
|
output := NewLimiter(NewTestOutput(func(data []byte) {
|
|
wg.Done()
|
|
}), 10)
|
|
wg.Add(10)
|
|
|
|
Plugins.Inputs = []io.Reader{input}
|
|
Plugins.Outputs = []io.Writer{output}
|
|
|
|
go Start(quit)
|
|
|
|
for i := 0; i < 100; i++ {
|
|
input.EmitGET()
|
|
}
|
|
|
|
wg.Wait()
|
|
|
|
close(quit)
|
|
}
|