improving code coverage

This commit is contained in:
Julien Neuhart
2018-04-05 10:36:38 +02:00
parent 15916e80e6
commit ee15a52001
8 changed files with 95 additions and 14 deletions

View File

@@ -161,8 +161,10 @@ var levels = map[string]logrus.Level{
type wrongLoggingLevelError struct{}
const wrongLoggingLevelErrorMessage = "Accepted values for logging level: DEBUG, INFO, WARN, ERROR, FATAL, PANIC"
func (e *wrongLoggingLevelError) Error() string {
return "Accepted values for logging level: DEBUG, INFO, WARN, ERROR, FATAL, PANIC"
return wrongLoggingLevelErrorMessage
}
// getLoggingLevelFromFileConfig returns a logrus level if a matching was found
@@ -186,8 +188,10 @@ var formatters = map[string]logrus.Formatter{
type wrongLoggingFormatError struct{}
const wrongLoggingFormatErrorMessage = "Accepted value for logging format: text, json"
func (e *wrongLoggingFormatError) Error() string {
return "Accepted value for logging format: text, json"
return wrongLoggingFormatErrorMessage
}
// getLoggingLevelFromFileConfig returns a logrus Formatter if a matching was found

View File

@@ -53,3 +53,17 @@ func TestNewAppConfig(t *testing.T) {
t.Error("AppConfig should have been instantiated!")
}
}
func TestWrongLoggingLevelError(t *testing.T) {
err := &wrongLoggingLevelError{}
if err.Error() != wrongLoggingLevelErrorMessage {
t.Errorf("Error returned a wrong message: got %s want %s", err.Error(), wrongLoggingLevelErrorMessage)
}
}
func TestWrongLoggingFormatError(t *testing.T) {
err := &wrongLoggingFormatError{}
if err.Error() != wrongLoggingFormatErrorMessage {
t.Errorf("Error returned a wrong message: got %s want %s", err.Error(), wrongLoggingFormatErrorMessage)
}
}