Fixed tests

This commit is contained in:
Leonid Bugaev
2014-01-29 21:10:35 +06:00
parent 38b171d357
commit 9a32742653
2 changed files with 5 additions and 10 deletions
+2 -6
View File
@@ -99,7 +99,7 @@ func (o *HTTPOutput) Write(data []byte) (n int, err error) {
buf := make([]byte, len(data))
copy(buf, data)
go o.sendRequest(buf)
o.buf <- buf
return len(data), nil
}
@@ -115,11 +115,7 @@ func (o *HTTPOutput) sendRequest(client *http.Client, data []byte) {
if len(o.methods) > 0 && !o.methods.Contains(request.Method) {
return
}
client := &http.Client{
CheckRedirect: customCheckRedirect,
}
// Change HOST of original request
URL := o.address + request.URL.Path + "?" + request.URL.RawQuery
+3 -4
View File
@@ -28,9 +28,7 @@ func TestHTTPOutput(t *testing.T) {
input := NewTestInput()
headers := HTTPHeaders{HTTPHeader{"User-Agent", "Gor"}}
methods := HTTPMethods{"GET", "PUT", "POST"}
output := NewHTTPOutput("127.0.0.1:50003", headers, methods, "")
listener := startHTTP(func(req *http.Request) {
if req.Header.Get("User-Agent") != "Gor" {
@@ -44,7 +42,7 @@ func TestHTTPOutput(t *testing.T) {
wg.Done()
})
output := NewHTTPOutput(listener.Addr().String(), headers, "")
output := NewHTTPOutput(listener.Addr().String(), headers, methods, "")
Plugins.Inputs = []io.Reader{input}
Plugins.Outputs = []io.Writer{output}
@@ -70,13 +68,14 @@ func BenchmarkHTTPOutput(b *testing.B) {
input := NewTestInput()
headers := HTTPHeaders{HTTPHeader{"User-Agent", "Gor"}}
methods := HTTPMethods{"GET", "PUT", "POST"}
listener := startHTTP(func(req *http.Request) {
time.Sleep(50 * time.Millisecond)
wg.Done()
})
output := NewHTTPOutput(listener.Addr().String(), headers, "")
output := NewHTTPOutput(listener.Addr().String(), headers, methods, "")
Plugins.Inputs = []io.Reader{input}
Plugins.Outputs = []io.Writer{output}