From 2afafe6911b65916389335079d5cded536e1f6d2 Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Tue, 4 Jul 2017 11:01:16 +0200 Subject: [PATCH] agent: refactor: use handler for test http tls server --- agent/check_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/agent/check_test.go b/agent/check_test.go index 5999fbf485..4416d7c876 100644 --- a/agent/check_test.go +++ b/agent/check_test.go @@ -351,18 +351,18 @@ func TestCheckHTTP_TLSSkipVerify_defaultFalse(t *testing.T) { } } -func mockTLSHTTPServer(code int) *httptest.Server { - return httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { +func largeBodyHandler(code int) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // Body larger than 4k limit body := bytes.Repeat([]byte{'a'}, 2*CheckBufSize) w.WriteHeader(code) w.Write(body) - })) + }) } func TestCheckHTTP_TLSSkipVerify_true_pass(t *testing.T) { t.Parallel() - server := mockTLSHTTPServer(200) + server := httptest.NewTLSServer(largeBodyHandler(200)) defer server.Close() notif := mock.NewNotify() @@ -391,7 +391,7 @@ func TestCheckHTTP_TLSSkipVerify_true_pass(t *testing.T) { func TestCheckHTTP_TLSSkipVerify_true_fail(t *testing.T) { t.Parallel() - server := mockTLSHTTPServer(500) + server := httptest.NewTLSServer(largeBodyHandler(500)) defer server.Close() notif := mock.NewNotify() @@ -419,7 +419,7 @@ func TestCheckHTTP_TLSSkipVerify_true_fail(t *testing.T) { func TestCheckHTTP_TLSSkipVerify_false(t *testing.T) { t.Parallel() - server := mockTLSHTTPServer(200) + server := httptest.NewTLSServer(largeBodyHandler(200)) defer server.Close() notif := mock.NewNotify()