mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-15 03:42:15 +01:00
improving code coverage
This commit is contained in:
@@ -43,8 +43,10 @@ func FindAuthorizedContentType(h http.Header) (ContentType, error) {
|
||||
|
||||
type notAuthorizedFileContentTypeError struct{}
|
||||
|
||||
const notAuthorizedFileContentTypeErrorMessage = "Unable to detect an authorized file content type"
|
||||
|
||||
func (e *notAuthorizedFileContentTypeError) Error() string {
|
||||
return fmt.Sprintf("Unable to detect a file content type")
|
||||
return notAuthorizedFileContentTypeErrorMessage
|
||||
}
|
||||
|
||||
// SniffContentType tries to detect the content type of a file.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
@@ -40,3 +41,18 @@ func TestSniffContentType(t *testing.T) {
|
||||
t.Error("It should have been able to retrieve an authorized content type from a PDF file!")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotAuthorizedContentTypeError(t *testing.T) {
|
||||
err := ¬AuthorizedContentTypeError{}
|
||||
message := fmt.Sprintf("Accepted values for 'Content-Type': %s, %s", OctetStreamContentType, MultipartFormDataContentType)
|
||||
if err.Error() != message {
|
||||
t.Errorf("Error returned a wrong message: got %s want %s", err.Error(), message)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotAuthorizedFileContentTypeError(t *testing.T) {
|
||||
err := ¬AuthorizedFileContentTypeError{}
|
||||
if err.Error() != notAuthorizedFileContentTypeErrorMessage {
|
||||
t.Errorf("Error returned a wrong message: got %s want %s", err.Error(), notAuthorizedFileContentTypeErrorMessage)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user