Adding field names into the table driven test and removed zero values. (#85)

This commit is contained in:
Todd Knight authored and GitHub committed 2020-05-29 07:49:14 -07:00
1 parent 0c7f6da936
commit 40c14d8232
1 file changed
+54 -77
+54 -77
View File
@@ -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,
},
}