mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-14 11:22:15 +01:00
improving code coverage
This commit is contained in:
@@ -30,8 +30,10 @@ func WithContentType(r *http.Request, contentType ghttp.ContentType) *http.Reque
|
||||
|
||||
type contentTypeNotFoundError struct{}
|
||||
|
||||
const contentTypeNotFoundErrorMessage = "The 'Content-Type' was not found in request context"
|
||||
|
||||
func (e *contentTypeNotFoundError) Error() string {
|
||||
return "The 'Content-Type' was not found in request context"
|
||||
return contentTypeNotFoundErrorMessage
|
||||
}
|
||||
|
||||
// GetContentType returns the content type if found in
|
||||
@@ -57,8 +59,10 @@ func WithConverter(r *http.Request, converter *converter.Converter) *http.Reques
|
||||
|
||||
type converterNotFoundError struct{}
|
||||
|
||||
const converterNotFoundErrorMessage = "The converter was not found in request context"
|
||||
|
||||
func (e *converterNotFoundError) Error() string {
|
||||
return "The converter was not found in request context"
|
||||
return converterNotFoundErrorMessage
|
||||
}
|
||||
|
||||
// GetConverter returns the converter if found in
|
||||
@@ -84,8 +88,10 @@ func WithResultFilePath(r *http.Request, resultFilePath string) *http.Request {
|
||||
|
||||
type resultFilePathNotFoundError struct{}
|
||||
|
||||
const resultFilePathNotFoundErrorMessage = "The result file path was not found in request context"
|
||||
|
||||
func (e *resultFilePathNotFoundError) Error() string {
|
||||
return "The result file path was not found in request context"
|
||||
return resultFilePathNotFoundErrorMessage
|
||||
}
|
||||
|
||||
// GetResultFilePath returns the result file path if found in
|
||||
|
||||
@@ -75,3 +75,24 @@ func TestGetResultFilePath(t *testing.T) {
|
||||
t.Error("Context should have a converter entry!")
|
||||
}
|
||||
}
|
||||
|
||||
func TestContentTypeNotFoundError(t *testing.T) {
|
||||
err := &contentTypeNotFoundError{}
|
||||
if err.Error() != contentTypeNotFoundErrorMessage {
|
||||
t.Errorf("Error returned a wrong message: got %s want %s", err.Error(), contentTypeNotFoundErrorMessage)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConverterNotFoundError(t *testing.T) {
|
||||
err := &converterNotFoundError{}
|
||||
if err.Error() != converterNotFoundErrorMessage {
|
||||
t.Errorf("Error returned a wrong message: got %s want %s", err.Error(), converterNotFoundErrorMessage)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResultFilePathNotFoundError(t *testing.T) {
|
||||
err := &resultFilePathNotFoundError{}
|
||||
if err.Error() != resultFilePathNotFoundErrorMessage {
|
||||
t.Errorf("Error returned a wrong message: got %s want %s", err.Error(), resultFilePathNotFoundErrorMessage)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user