-
Notifications
You must be signed in to change notification settings - Fork 44
/
rollingwriter_test.go
34 lines (30 loc) · 1003 Bytes
/
rollingwriter_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
package rollingwriter
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestOptions(t *testing.T) {
options := []Option{
WithTimeTagFormat("200601021504"), WithLogPath("./"), WithFileName("foo"),
WithAsynchronous(), WithBuffer(), WithBufferThershould(8), WithCompress(), WithLock(),
WithMaxRemain(3), WithRollingVolumeSize("100mb"), WithRollingTimePattern("0 0 0 * * *"),
}
cfg := NewDefaultConfig()
for _, opt := range options {
opt(&cfg)
}
destcfg := Config{
LogPath: "./",
TimeTagFormat: "200601021504",
FileName: "foo",
FileExtension: "log",
MaxRemain: 3, // disable auto delete
RollingPolicy: TimeRolling, // TimeRotate by default
RollingTimePattern: "0 0 0 * * *", // Rolling at 00:00 AM everyday
RollingVolumeSize: "100mb",
WriterMode: "lock",
BufferWriterThershould: 8,
Compress: true,
}
assert.Equal(t, cfg, destcfg)
}