mirror of
https://gitee.com/johng/gf.git
synced 2024-12-02 04:07:47 +08:00
fix issue in gring/ghttp
This commit is contained in:
parent
2bf9bc98a7
commit
a31108e753
@ -15,13 +15,13 @@ import (
|
||||
)
|
||||
|
||||
var length = 10000
|
||||
var ring = gring.New(length, true)
|
||||
var ringObject = gring.New(length, true)
|
||||
|
||||
func BenchmarkRing_Put(b *testing.B) {
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
i := 0
|
||||
for pb.Next() {
|
||||
ring.Put(i)
|
||||
ringObject.Put(i)
|
||||
i++
|
||||
}
|
||||
})
|
||||
@ -31,7 +31,7 @@ func BenchmarkRing_Next(b *testing.B) {
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
i := 0
|
||||
for pb.Next() {
|
||||
ring.Next()
|
||||
ringObject.Next()
|
||||
i++
|
||||
}
|
||||
})
|
||||
@ -41,7 +41,7 @@ func BenchmarkRing_Set(b *testing.B) {
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
i := 0
|
||||
for pb.Next() {
|
||||
ring.Set(i)
|
||||
ringObject.Set(i)
|
||||
i++
|
||||
}
|
||||
})
|
||||
@ -51,7 +51,7 @@ func BenchmarkRing_Len(b *testing.B) {
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
i := 0
|
||||
for pb.Next() {
|
||||
ring.Len()
|
||||
ringObject.Len()
|
||||
i++
|
||||
}
|
||||
})
|
||||
@ -61,7 +61,7 @@ func BenchmarkRing_Cap(b *testing.B) {
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
i := 0
|
||||
for pb.Next() {
|
||||
ring.Cap()
|
||||
ringObject.Cap()
|
||||
i++
|
||||
}
|
||||
})
|
||||
|
@ -202,6 +202,8 @@ func GetServer(name ...interface{}) *Server {
|
||||
if s := serverMapping.Get(sname); s != nil {
|
||||
return s.(*Server)
|
||||
}
|
||||
sessionStorage := gkvdb.Instance(defaultServerConfig.SessionStoragePath)
|
||||
sessionStorage.SetOptions(gkvdb.DefaultOptions(defaultServerConfig.SessionStoragePath))
|
||||
s := &Server{
|
||||
name: sname,
|
||||
servers: make([]*gracefulServer, 0),
|
||||
@ -212,7 +214,7 @@ func GetServer(name ...interface{}) *Server {
|
||||
serveCache: gcache.New(),
|
||||
routesMap: make(map[string][]registeredRouteItem),
|
||||
sessions: gcache.New(),
|
||||
sessionStorage: gkvdb.New(gkvdb.DefaultOptions(defaultServerConfig.SessionStoragePath)),
|
||||
sessionStorage: sessionStorage,
|
||||
servedCount: gtype.NewInt(),
|
||||
logger: glog.New(),
|
||||
}
|
||||
|
@ -38,8 +38,10 @@ func Test_Params_Struct(t *testing.T) {
|
||||
if m := r.GetMap(); len(m) > 0 {
|
||||
user := (*User)(nil)
|
||||
r.GetToStruct(&user)
|
||||
if user != nil {
|
||||
r.Response.Write(user.Id, user.Name, user.Pass1, user.Pass2)
|
||||
}
|
||||
}
|
||||
})
|
||||
s.BindHandler("/struct-valid", func(r *ghttp.Request) {
|
||||
if m := r.GetMap(); len(m) > 0 {
|
||||
@ -62,6 +64,7 @@ func Test_Params_Struct(t *testing.T) {
|
||||
gtest.Assert(client.GetContent("/struct1", `id=1&name=john&password1=123&password2=456`), `1john123456`)
|
||||
gtest.Assert(client.PostContent("/struct1", `id=1&name=john&password1=123&password2=456`), `1john123456`)
|
||||
gtest.Assert(client.PostContent("/struct2", `id=1&name=john&password1=123&password2=456`), `1john123456`)
|
||||
gtest.Assert(client.PostContent("/struct2", ``), ``)
|
||||
gtest.Assert(client.PostContent("/struct-valid", `id=1&name=john&password1=123&password2=0`), `{"passwd1":{"length":"字段长度为2到20个字符","password3":"密码强度不足"}}`)
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user