mirror of
https://gitee.com/johng/gf.git
synced 2024-12-02 04:07:47 +08:00
fix issue in unit testing case for package gctx/glog
This commit is contained in:
parent
fa45715416
commit
4de74464ac
@ -18,7 +18,7 @@ func Test_New(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
ctx := gctx.New()
|
||||
t.AssertNE(ctx, nil)
|
||||
t.Assert(gctx.CtxId(ctx), "")
|
||||
t.AssertNE(gctx.CtxId(ctx), "")
|
||||
})
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ func Test_WithCtx(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
ctx := context.WithValue(context.TODO(), "TEST", 1)
|
||||
ctx = gctx.WithCtx(ctx)
|
||||
t.Assert(gctx.CtxId(ctx), "")
|
||||
t.AssertNE(gctx.CtxId(ctx), "")
|
||||
t.Assert(ctx.Value("TEST"), 1)
|
||||
})
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"github.com/gogf/gf/v2/os/gfile"
|
||||
"github.com/gogf/gf/v2/os/glog"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
@ -55,16 +54,6 @@ func Test_Ctx_Config(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Ctx_CtxKey(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
w := bytes.NewBuffer(nil)
|
||||
l := glog.NewWithWriter(w)
|
||||
l.Print(gctx.WithCtxId(context.TODO(), "abcdefg"), 1, 2, 3)
|
||||
t.Assert(gstr.Count(w.String(), "abcdefg"), 1)
|
||||
t.Assert(gstr.Count(w.String(), "1 2 3"), 1)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Concurrent(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
c := 1000
|
||||
|
Loading…
Reference in New Issue
Block a user