From 378dcc6044f11721d0eabc1ac47113120fbf4e5c Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski <ayufan@ayufan.eu> Date: Wed, 1 Mar 2017 22:17:35 +0100 Subject: [PATCH] Fix tests for Go 1.5 and 1.6 --- internal/builds/register_test.go | 2 +- internal/helper/helpers_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/builds/register_test.go b/internal/builds/register_test.go index fcd0389db65b..f28068d1b354 100644 --- a/internal/builds/register_test.go +++ b/internal/builds/register_test.go @@ -26,7 +26,7 @@ func expectHandlerWithWatcher(t *testing.T, watchHandler WatchKeyHandler, data s h := RegisterHandler(echoRequestFunc, watchHandler, time.Second) rw := httptest.NewRecorder() - req := httptest.NewRequest("POST", "/", bytes.NewBufferString(data)) + req, _ := http.NewRequest("POST", "/", bytes.NewBufferString(data)) req.Header.Set("Content-Type", contentType) h.ServeHTTP(rw, req) diff --git a/internal/helper/helpers_test.go b/internal/helper/helpers_test.go index e0712c682308..66888adc4921 100644 --- a/internal/helper/helpers_test.go +++ b/internal/helper/helpers_test.go @@ -56,7 +56,7 @@ func TestSetForwardedForGeneratesHeader(t *testing.T) { func TestReadRequestBody(t *testing.T) { data := []byte("123456") rw := httptest.NewRecorder() - req := httptest.NewRequest("POST", "/test", bytes.NewBuffer(data)) + req, _ := http.NewRequest("POST", "/test", bytes.NewBuffer(data)) result, err := ReadRequestBody(rw, req, 1000) assert.NoError(t, err) @@ -66,7 +66,7 @@ func TestReadRequestBody(t *testing.T) { func TestReadRequestBodyLimit(t *testing.T) { data := []byte("123456") rw := httptest.NewRecorder() - req := httptest.NewRequest("POST", "/test", bytes.NewBuffer(data)) + req, _ := http.NewRequest("POST", "/test", bytes.NewBuffer(data)) result, err := ReadRequestBody(rw, req, 2) assert.Error(t, err) @@ -76,7 +76,7 @@ func TestReadRequestBodyLimit(t *testing.T) { func TestCloneRequestWithBody(t *testing.T) { input := []byte("test") newInput := []byte("new body") - req := httptest.NewRequest("POST", "/test", bytes.NewBuffer(input)) + req, _ := http.NewRequest("POST", "/test", bytes.NewBuffer(input)) newReq := CloneRequestWithNewBody(req, newInput) assert.NotEqual(t, req, newReq) @@ -89,7 +89,7 @@ func TestCloneRequestWithBody(t *testing.T) { } func TestApplicationJson(t *testing.T) { - req := httptest.NewRequest("POST", "/test", nil) + req, _ := http.NewRequest("POST", "/test", nil) req.Header.Set("Content-Type", "application/json") assert.True(t, IsApplicationJson(req), "expected to match 'application/json' as 'application/json'") -- GitLab