OSDN Git Service

add bytom logs into files
[bytom/bytom.git] / vendor / github.com / lestrrat-go / file-rotatelogs / internal_test.go
1 package rotatelogs
2
3 import (
4         "fmt"
5         "testing"
6         "time"
7
8         "github.com/jonboulle/clockwork"
9         "github.com/stretchr/testify/assert"
10 )
11
12 func TestGenFilename(t *testing.T) {
13         // Mock time
14         ts := []time.Time{
15                 time.Time{},
16                 (time.Time{}).Add(24 * time.Hour),
17         }
18
19         for _, xt := range ts {
20                 rl, err := New(
21                         "/path/to/%Y/%m/%d",
22                         WithClock(clockwork.NewFakeClockAt(xt)),
23                 )
24                 if !assert.NoError(t, err, "New should succeed") {
25                         return
26                 }
27
28                 defer rl.Close()
29
30                 fn := rl.genFilename()
31                 expected := fmt.Sprintf("/path/to/%04d/%02d/%02d",
32                         xt.Year(),
33                         xt.Month(),
34                         xt.Day(),
35                 )
36
37                 if !assert.Equal(t, expected, fn) {
38                         return
39                 }
40         }
41 }