improving tests coverage of http package + using a real word request when testing enforceContentTypeHandler

This commit is contained in:
Julien Neuhart
2018-04-11 17:38:34 +02:00
parent 158bc9b3ea
commit d43fb62cd8
3 changed files with 15 additions and 10 deletions

View File

@@ -20,6 +20,13 @@ func TestCheckAuthorizedContentType(t *testing.T) {
if err := CheckAuthorizedContentType(req.Header); err != nil {
t.Error("Function should have been able to retrieve an authorized content type from request's header")
}
// case 3: uses a request with a composed content type entry in its header.
req.Header.Set("Content-Type", "multipart/form-data; boundary=—-WebKitFormBoundary7MA4YWxkTrZu0gW")
if err := CheckAuthorizedContentType(req.Header); err != nil {
t.Error("Function should have been able to retrieve an authorized content type from request's header")
}
}
func TestNotAuthorizedContentTypeError(t *testing.T) {