Skip to content

Commit cc322e6

Browse files
committed
add tests for file log functions
1 parent 9a737f7 commit cc322e6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

internal/log/log_file_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package log
2+
3+
import (
4+
"testing"
5+
6+
"github.com/cybertec-postgresql/pg_timetable/internal/config"
7+
"github.com/sirupsen/logrus"
8+
"github.com/stretchr/testify/assert"
9+
"gopkg.in/natefinch/lumberjack.v2"
10+
)
11+
12+
func TestGetLogFileWriter(t *testing.T) {
13+
assert.IsType(t, getLogFileWriter(config.LoggingOpts{LogFileRotate: true}), &lumberjack.Logger{})
14+
assert.IsType(t, getLogFileWriter(config.LoggingOpts{LogFileRotate: false}), "string")
15+
}
16+
17+
func TestGetLogFileFormatter(t *testing.T) {
18+
assert.IsType(t, getLogFileFormatter(config.LoggingOpts{LogFileFormat: "json"}), &logrus.JSONFormatter{})
19+
assert.IsType(t, getLogFileFormatter(config.LoggingOpts{LogFileFormat: "blah"}), &logrus.JSONFormatter{})
20+
assert.IsType(t, getLogFileFormatter(config.LoggingOpts{LogFileFormat: "text"}), &logrus.TextFormatter{})
21+
}

0 commit comments

Comments
 (0)