-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_test.go
58 lines (48 loc) · 1.05 KB
/
file_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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package pslog
import (
"testing"
"time"
"gitee.com/xuesongtao/gotool/base"
"gitee.com/xuesongtao/gotool/xfile"
)
var (
fileInfo = &FileInfo{}
)
func TestParse(t *testing.T) {
fileInfo.Parse("./ps-log/_example/parselog/main.go")
t.Log(fileInfo.Dir, fileInfo.Name)
t.Log(fileInfo.FileName())
}
func TestGetContent(t *testing.T) {
tmp := tmpDir + "/test.log"
f := &FileInfo{}
for i := 0; i < 3; i++ {
_, err := f.putContent(tmp, "line:"+base.ToString(i)+"test"+time.Now().Format(base.DatetimeFmt)+"\n")
if err != nil {
t.Fatal(err)
}
time.Sleep(time.Second)
row, err := f.getContent(tmp)
if err != nil {
t.Fatal(err)
}
t.Log(row)
}
filePool.Close()
time.Sleep(time.Second * 2)
}
func TestGetContent1(t *testing.T) {
tmp := tmpDir + "/test.log"
for i := 0; i < 3; i++ {
_, err := xfile.PutContent(tmp, "line:"+base.ToString(i)+"test"+time.Now().Format(base.DatetimeFmt)+"\n")
if err != nil {
t.Fatal(err)
}
time.Sleep(time.Second)
row, err := xfile.GetContent(tmp)
if err != nil {
t.Fatal(err)
}
t.Log(row)
}
}