mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
unit testing cases update for package gredis/glog
This commit is contained in:
@ -139,21 +139,11 @@ func Test_Instance(t *testing.T) {
|
||||
|
||||
func Test_Error(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
//config1 := &gredis.Config{
|
||||
// Host: "127.0.0.2",
|
||||
// Port: 6379,
|
||||
// Db: 1,
|
||||
// ConnectTimeout: time.Second,
|
||||
//}
|
||||
//redis := gredis.New(config1)
|
||||
//_, err := redis.Do("info")
|
||||
//t.AssertNE(err, nil)
|
||||
|
||||
config1 := &gredis.Config{
|
||||
Host: "127.0.0.1",
|
||||
Port: 6379,
|
||||
Db: 1,
|
||||
Pass: "666666",
|
||||
Host: "192.111.0.2",
|
||||
Port: 6379,
|
||||
Db: 1,
|
||||
ConnectTimeout: time.Second,
|
||||
}
|
||||
redis := gredis.New(config1)
|
||||
_, err := redis.Do("info")
|
||||
|
||||
@ -115,36 +115,38 @@ func Test_Stack(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
//func Test_StackWithFilter(t *testing.T) {
|
||||
// gtest.C(t, func(t *gtest.T) {
|
||||
// path := gfile.TempDir(gtime.TimestampNanoStr())
|
||||
// file := fmt.Sprintf(`%d.log`, gtime.TimestampNano())
|
||||
//
|
||||
// err := gfile.Mkdir(path)
|
||||
// t.Assert(err, nil)
|
||||
// defer gfile.Remove(path)
|
||||
//
|
||||
// Path(path).File(file).StackWithFilter("none").Stdout(false).Error(1, 2, 3)
|
||||
// content := gfile.GetContents(gfile.Join(path, file))
|
||||
// t.Assert(gstr.Count(content, defaultLevelPrefixes[LEVEL_ERRO]), 1)
|
||||
// t.Assert(gstr.Count(content, "1 2 3"), 1)
|
||||
// t.Assert(gstr.Count(content, "Stack"), 1)
|
||||
// })
|
||||
// gtest.C(t, func(t *gtest.T) {
|
||||
// path := gfile.TempDir(gtime.TimestampNanoStr())
|
||||
// file := fmt.Sprintf(`%d.log`, gtime.TimestampNano())
|
||||
//
|
||||
// err := gfile.Mkdir(path)
|
||||
// t.Assert(err, nil)
|
||||
// defer gfile.Remove(path)
|
||||
//
|
||||
// Path(path).File(file).StackWithFilter("gogf").Stdout(false).Error(1, 2, 3)
|
||||
// content := gfile.GetContents(gfile.Join(path, file))
|
||||
// t.Assert(gstr.Count(content, defaultLevelPrefixes[LEVEL_ERRO]), 1)
|
||||
// t.Assert(gstr.Count(content, "1 2 3"), 1)
|
||||
// t.Assert(gstr.Count(content, "Stack"), 0)
|
||||
// })
|
||||
//}
|
||||
func Test_StackWithFilter(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
path := gfile.TempDir(gtime.TimestampNanoStr())
|
||||
file := fmt.Sprintf(`%d.log`, gtime.TimestampNano())
|
||||
|
||||
err := gfile.Mkdir(path)
|
||||
t.Assert(err, nil)
|
||||
defer gfile.Remove(path)
|
||||
|
||||
Path(path).File(file).StackWithFilter("none").Stdout(false).Error(1, 2, 3)
|
||||
content := gfile.GetContents(gfile.Join(path, file))
|
||||
t.Assert(gstr.Count(content, defaultLevelPrefixes[LEVEL_ERRO]), 1)
|
||||
t.Assert(gstr.Count(content, "1 2 3"), 1)
|
||||
t.Assert(gstr.Count(content, "Stack"), 1)
|
||||
fmt.Println("Content:")
|
||||
fmt.Println(content)
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
path := gfile.TempDir(gtime.TimestampNanoStr())
|
||||
file := fmt.Sprintf(`%d.log`, gtime.TimestampNano())
|
||||
|
||||
err := gfile.Mkdir(path)
|
||||
t.Assert(err, nil)
|
||||
defer gfile.Remove(path)
|
||||
|
||||
Path(path).File(file).StackWithFilter("gogf").Stdout(false).Error(1, 2, 3)
|
||||
content := gfile.GetContents(gfile.Join(path, file))
|
||||
t.Assert(gstr.Count(content, defaultLevelPrefixes[LEVEL_ERRO]), 1)
|
||||
t.Assert(gstr.Count(content, "1 2 3"), 1)
|
||||
t.Assert(gstr.Count(content, "Stack"), 0)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Header(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
|
||||
Reference in New Issue
Block a user