-
Notifications
You must be signed in to change notification settings - Fork 0
/
rotate_test.go
36 lines (31 loc) · 909 Bytes
/
rotate_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
package zl
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_newRotator(t *testing.T) {
t.Run("default", func(t *testing.T) {
ret := newRotator()
assert.Equal(t, "./log/app.jsonl", ret.Filename)
assert.Equal(t, 100, ret.MaxSize)
assert.Equal(t, 3, ret.MaxBackups)
assert.Equal(t, 7, ret.MaxAge)
assert.Equal(t, false, ret.LocalTime)
assert.Equal(t, false, ret.Compress)
})
t.Run("set options", func(t *testing.T) {
SetRotateFileName("./log/Test_newRotator.jsonl")
SetRotateMaxSize(1000)
SetRotateMaxBackups(5)
SetRotateMaxAge(14)
SetRotateLocalTime(true)
SetRotateCompress(true)
ret := newRotator()
assert.Equal(t, "./log/Test_newRotator.jsonl", ret.Filename)
assert.Equal(t, 1000, ret.MaxSize)
assert.Equal(t, 5, ret.MaxBackups)
assert.Equal(t, 14, ret.MaxAge)
assert.Equal(t, true, ret.LocalTime)
assert.Equal(t, true, ret.Compress)
})
}