gophish/logger/logger_test.go
Jordan Wright caede2e40b
Refactoring Logging (#1722)
* Added ParseLevel to set log level (#1671)
* Moved logger config into the logger package for better decoupling. Added logging tests.

Co-authored-by: Amal Alkhamees <Amalkh5@users.noreply.github.com>
2020-01-16 22:21:58 -06:00

26 lines
591 B
Go

package logger
import "testing"
import "github.com/sirupsen/logrus"
func TestLogLevel(t *testing.T) {
tests := map[string]logrus.Level{
"": logrus.InfoLevel,
"debug": logrus.DebugLevel,
"info": logrus.InfoLevel,
"error": logrus.ErrorLevel,
"fatal": logrus.FatalLevel,
}
config := &Config{}
for level, expected := range tests {
config.Level = level
err := Setup(config)
if err != nil {
t.Fatalf("error setting logging level %v", err)
}
if Logger.Level != expected {
t.Fatalf("invalid logging level. expected %v got %v", expected, Logger.Level)
}
}
}