From f7b3adc8cd778cd60f2d6adf2d3618417dd7ad34 Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Sat, 2 Nov 2013 19:46:46 +0100 Subject: [PATCH] Add delay to http server for proper testing --- output_http_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/output_http_test.go b/output_http_test.go index 6e61156..5461df9 100644 --- a/output_http_test.go +++ b/output_http_test.go @@ -6,11 +6,12 @@ import ( "net/http" "sync" "testing" + "time" ) func startHTTP(cb func(*http.Request)) net.Listener { handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - cb(r) + go cb(r) }) listener, _ := net.Listen("tcp", ":0") @@ -63,7 +64,8 @@ func BenchmarkHTTPOutput(b *testing.B) { headers := HTTPHeaders{HTTPHeader{"User-Agent", "Gor"}} listener := startHTTP(func(req *http.Request) { - go wg.Done() + time.Sleep(50 * time.Millisecond) + wg.Done() }) output := NewHTTPOutput(listener.Addr().String(), headers, "")