refactoring all tests but handlers and process

This commit is contained in:
Julien Neuhart
2018-04-11 13:30:02 +02:00
parent 6b5a214462
commit a1abbc55a2
6 changed files with 84 additions and 70 deletions

View File

@@ -12,20 +12,20 @@ func TestCheckAuthorizedContentType(t *testing.T) {
// case 1: uses a request without a content type entry in its header.
if err := CheckAuthorizedContentType(req.Header); err == nil {
t.Error("It should not have been able to retrieve an authorized content type from header!")
t.Error("Function should not have been able to retrieve an authorized content type from request's header")
}
// case 2: uses a request with a content type entry in its header.
req.Header.Set("Content-Type", string(MultipartFormDataContentType))
if err := CheckAuthorizedContentType(req.Header); err != nil {
t.Error("It should have been able to retrieve an authorized content type from header!")
t.Error("Function should have been able to retrieve an authorized content type from request's header")
}
}
func TestNotAuthorizedContentTypeError(t *testing.T) {
err := &notAuthorizedContentTypeError{}
message := fmt.Sprintf("Accepted value for 'Content-Type': %s", MultipartFormDataContentType)
if err.Error() != message {
t.Errorf("Error returned a wrong message: got %s want %s", err.Error(), message)
expected := fmt.Sprintf("Accepted value for 'Content-Type': %s", MultipartFormDataContentType)
if err.Error() != expected {
t.Errorf("Error returned a wrong message: got '%s' want '%s'", err.Error(), expected)
}
}