-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathgonja_test.go
45 lines (38 loc) · 835 Bytes
/
gonja_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package gonja_test
import (
"flag"
"os"
"testing"
. "github.com/go-check/check"
log "github.com/sirupsen/logrus"
prefixed "github.com/x-cray/logrus-prefixed-formatter"
)
// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) { TestingT(t) }
var (
logLevel = flag.String("log.level", "", "Log Level")
)
func TestMain(m *testing.M) {
flag.Parse()
log.SetFormatter(&prefixed.TextFormatter{
ForceColors: true,
DisableTimestamp: true,
ForceFormatting: true,
})
switch *logLevel {
case "error":
log.SetLevel(log.ErrorLevel)
case "warning", "warn":
log.SetLevel(log.WarnLevel)
case "info":
log.SetLevel(log.InfoLevel)
case "debug":
log.SetLevel(log.DebugLevel)
case "trace":
log.SetLevel(log.TraceLevel)
default:
log.SetLevel(log.PanicLevel)
}
code := m.Run()
os.Exit(code)
}