mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
40 lines
628 B
Go
40 lines
628 B
Go
package gor
|
|
|
|
import (
|
|
"io"
|
|
"net/http"
|
|
"strings"
|
|
"sync"
|
|
"testing"
|
|
)
|
|
|
|
func TestRAWInput(t *testing.T) {
|
|
|
|
wg := new(sync.WaitGroup)
|
|
quit := make(chan int)
|
|
|
|
listener := startHTTP(func(req *http.Request) {})
|
|
|
|
input := NewRAWInput(listener.Addr().String())
|
|
output := NewTestOutput(func(data []byte) {
|
|
wg.Done()
|
|
})
|
|
|
|
Plugins.Inputs = []io.Reader{input}
|
|
Plugins.Outputs = []io.Writer{output}
|
|
|
|
address := strings.Replace(listener.Addr().String(), "[::]", "127.0.0.1", -1)
|
|
|
|
go Start(quit)
|
|
|
|
for i := 0; i < 100; i++ {
|
|
wg.Add(1)
|
|
res, _ := http.Get("http://" + address)
|
|
res.Body.Close()
|
|
}
|
|
|
|
wg.Wait()
|
|
|
|
close(quit)
|
|
}
|