From 40c14d82328a875ccc4ce64f91669df0fe82a500 Mon Sep 17 00:00:00 2001 From: Todd Knight Date: Fri, 29 May 2020 07:49:14 -0700 Subject: [PATCH] Adding field names into the table driven test and removed zero values. (#85) --- internal/servers/controller/cors_test.go | 131 ++++++++++------------- 1 file changed, 54 insertions(+), 77 deletions(-) diff --git a/internal/servers/controller/cors_test.go b/internal/servers/controller/cors_test.go index 7265d1752..fbc711a57 100644 --- a/internal/servers/controller/cors_test.go +++ b/internal/servers/controller/cors_test.go @@ -80,103 +80,80 @@ func TestHandler_CORS(t *testing.T) { listenerNum int }{ { - "disabled no origin", - http.MethodPost, - "", - http.StatusOK, - "", - "", - 1, + name: "disabled no origin", + method: http.MethodPost, + code: http.StatusOK, + listenerNum: 1, }, { - "disabled with origin", - http.MethodPost, - "foobar.com", - http.StatusOK, - "", - "", - 1, + name: "disabled with origin", + method: http.MethodPost, + origin: "foobar.com", + code: http.StatusOK, + listenerNum: 1, }, { - "enabled with no allowed origins and no origin defined", - http.MethodPost, - "", - http.StatusOK, - "", - "", - 2, + name: "enabled with no allowed origins and no origin defined", + method: http.MethodPost, + code: http.StatusOK, + listenerNum: 2, }, { - "enabled with no allowed origins and origin defined", - http.MethodPost, - "foobar.com", - http.StatusForbidden, - "", - "", - 2, + name: "enabled with no allowed origins and origin defined", + method: http.MethodPost, + origin: "foobar.com", + code: http.StatusForbidden, + listenerNum: 2, }, { - "enabled with allowed origins and no origin defined", - http.MethodPost, - "", - http.StatusOK, - "", - "", - 3, + name: "enabled with allowed origins and no origin defined", + method: http.MethodPost, + code: http.StatusOK, + listenerNum: 3, }, { - "enabled with allowed origins and bad origin defined", - http.MethodPost, - "flubber.com", - http.StatusForbidden, - "", - "", - 3, + name: "enabled with allowed origins and bad origin defined", + method: http.MethodPost, + origin: "flubber.com", + code: http.StatusForbidden, + listenerNum: 3, }, { - "enabled with allowed origins and good origin defined", - http.MethodPost, - "barfoo.com", - http.StatusOK, - "", - "", - 3, + name: "enabled with allowed origins and good origin defined", + method: http.MethodPost, + origin: "barfoo.com", + code: http.StatusOK, + listenerNum: 3, }, { - "enabled with wildcard origins and no origin defined", - http.MethodPost, - "", - http.StatusOK, - "", - "", - 4, + name: "enabled with wildcard origins and no origin defined", + method: http.MethodPost, + code: http.StatusOK, + listenerNum: 4, }, { - "enabled with wildcard origins and origin defined", - http.MethodPost, - "flubber.com", - http.StatusOK, - "", - "", - 4, + name: "enabled with wildcard origins and origin defined", + method: http.MethodPost, + origin: "flubber.com", + code: http.StatusOK, + listenerNum: 4, }, { - "wildcard origins with method list and good method", - http.MethodOptions, - "flubber.com", - http.StatusNoContent, - "DELETE", - "", - 4, + name: "wildcard origins with method list and good method", + method: http.MethodOptions, + origin: "flubber.com", + code: http.StatusNoContent, + acrmHeader: "DELETE", + listenerNum: 4, }, { - "wildcard origins with method list and bad method", - http.MethodOptions, - "flubber.com", - http.StatusMethodNotAllowed, - "BADSTUFF", - "X-Foobar", - 4, + name: "wildcard origins with method list and bad method", + method: http.MethodOptions, + origin: "flubber.com", + code: http.StatusMethodNotAllowed, + acrmHeader: "BADSTUFF", + allowedHeader: "X-Foobar", + listenerNum: 4, }, }