Refactoring main.go

This commit is contained in:
Joona Hoikkala
2016-11-27 22:09:13 +02:00
parent 74b82c87a6
commit e9f18c99d8
3 changed files with 61 additions and 32 deletions

25
util_test.go Normal file
View File

@ -0,0 +1,25 @@
package main
import (
log "github.com/Sirupsen/logrus"
"testing"
)
func TestSetupLogging(t *testing.T) {
for i, test := range []struct {
format string
level string
expected string
}{
{"text", "warning", "warning"},
{"json", "debug", "debug"},
{"text", "info", "info"},
{"json", "error", "error"},
{"text", "something", "warning"},
} {
setupLogging(test.format, test.level)
if log.GetLevel().String() != test.expected {
t.Errorf("Test %d: Expected loglevel %s but got %s", i, test.expected, log.GetLevel().String())
}
}
}