From d6ccb0fbb8c593a004423426d76a84d2fea683a1 Mon Sep 17 00:00:00 2001 From: Marius Date: Thu, 29 Sep 2016 21:18:12 +0200 Subject: [PATCH] Use actual header values as expectations in CORS test --- cors_test.go | 8 ++++---- handler_test.go | 6 +----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/cors_test.go b/cors_test.go index 875311a..6f42e07 100644 --- a/cors_test.go +++ b/cors_test.go @@ -22,9 +22,9 @@ func TestCORS(t *testing.T) { }, Code: http.StatusOK, ResHeader: map[string]string{ - "Access-Control-Allow-Headers": "", - "Access-Control-Allow-Methods": "", - "Access-Control-Max-Age": "", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Upload-Length, Upload-Offset, Tus-Resumable, Upload-Metadata", + "Access-Control-Allow-Methods": "POST, GET, HEAD, PATCH, DELETE, OPTIONS", + "Access-Control-Max-Age": "86400", "Access-Control-Allow-Origin": "tus.io", }, }).Run(handler, t) @@ -37,7 +37,7 @@ func TestCORS(t *testing.T) { }, Code: http.StatusMethodNotAllowed, ResHeader: map[string]string{ - "Access-Control-Expose-Headers": "", + "Access-Control-Expose-Headers": "Upload-Offset, Location, Upload-Length, Tus-Version, Tus-Resumable, Tus-Max-Size, Tus-Extension, Upload-Metadata", "Access-Control-Allow-Origin": "tus.io", }, }).Run(handler, t) diff --git a/handler_test.go b/handler_test.go index 87971a6..3a32813 100644 --- a/handler_test.go +++ b/handler_test.go @@ -61,11 +61,7 @@ func (test *httpTest) Run(handler http.Handler, t *testing.T) *httptest.Response for key, value := range test.ResHeader { header := w.HeaderMap.Get(key) - if value == "" && header == "" { - t.Errorf("Expected '%s' in response", key) - } - - if value != "" && value != header { + if value != header { t.Errorf("Expected '%s' as '%s' (got '%s')", value, key, header) } }