fix(test): cover log level configuration when running tests

This commit is contained in:
Łukasz Mierzwa
2018-08-21 10:23:17 +01:00
parent e14fc4cfcb
commit 3086638433

28
main_test.go Normal file
View File

@@ -0,0 +1,28 @@
package main
import (
"testing"
"github.com/prymitive/unsee/internal/config"
log "github.com/sirupsen/logrus"
)
func TestLogConfig(t *testing.T) {
logLevels := map[string]log.Level{
"debug": log.DebugLevel,
"info": log.InfoLevel,
"warning": log.WarnLevel,
"error": log.ErrorLevel,
"fatal": log.FatalLevel,
"panic": log.PanicLevel,
}
for val, level := range logLevels {
config.Config.Log.Level = val
setupLogger()
if log.GetLevel() != level {
t.Errorf("Config.Log.Level=%s resulted in invalid log level %s", val, log.GetLevel())
}
}
}