...
1 package log
2
3 import (
4 "testing"
5
6 "github.com/sirupsen/logrus"
7 "github.com/stretchr/testify/assert"
8 "gopkg.in/natefinch/lumberjack.v2"
9 )
10
11 func TestGetLogFileWriter(t *testing.T) {
12 assert.IsType(t, getLogFileWriter(CmdOpts{LogFileRotate: true}), &lumberjack.Logger{})
13 assert.IsType(t, getLogFileWriter(CmdOpts{LogFileRotate: false}), "string")
14 }
15
16 func TestGetLogFileFormatter(t *testing.T) {
17 assert.IsType(t, getLogFileFormatter(CmdOpts{LogFileFormat: "json"}), &logrus.JSONFormatter{})
18 assert.IsType(t, getLogFileFormatter(CmdOpts{LogFileFormat: "blah"}), &logrus.JSONFormatter{})
19 assert.IsType(t, getLogFileFormatter(CmdOpts{LogFileFormat: "text"}), &Formatter{})
20 }
21