fix issue in unit testing case for package gctx/glog

This commit is contained in:
John Guo 2021-12-16 23:38:40 +08:00
parent fa45715416
commit 4de74464ac
2 changed files with 2 additions and 13 deletions

View File

@ -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)
})
}

View File

@ -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