mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
fix usage for garray.PopRand
This commit is contained in:
@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_Client_Basic(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/hello", func(r *ghttp.Request) {
|
||||
r.Response.Write("hello")
|
||||
@ -43,7 +43,7 @@ func Test_Client_Basic(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Client_BasicAuth(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/auth", func(r *ghttp.Request) {
|
||||
if r.BasicAuth("admin", "admin") {
|
||||
@ -67,7 +67,7 @@ func Test_Client_BasicAuth(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Client_Cookie(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/cookie", func(r *ghttp.Request) {
|
||||
r.Response.Write(r.Cookie.Get("test"))
|
||||
@ -88,7 +88,7 @@ func Test_Client_Cookie(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Client_Cookies(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/cookie", func(r *ghttp.Request) {
|
||||
r.Cookie.Set("test1", "1")
|
||||
@ -121,7 +121,7 @@ func Test_Client_Cookies(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Client_Chain_Header(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/header1", func(r *ghttp.Request) {
|
||||
r.Response.Write(r.Header.Get("test1"))
|
||||
@ -146,7 +146,7 @@ func Test_Client_Chain_Header(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Client_Chain_Context(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/context", func(r *ghttp.Request) {
|
||||
time.Sleep(1 * time.Second)
|
||||
@ -171,7 +171,7 @@ func Test_Client_Chain_Context(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Client_Chain_Timeout(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/timeout", func(r *ghttp.Request) {
|
||||
time.Sleep(1 * time.Second)
|
||||
@ -192,7 +192,7 @@ func Test_Client_Chain_Timeout(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Client_Chain_ContentJson(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/json", func(r *ghttp.Request) {
|
||||
r.Response.Write(r.Get("name"), r.Get("score"))
|
||||
@ -221,7 +221,7 @@ func Test_Client_Chain_ContentJson(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Client_Chain_ContentXml(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/xml", func(r *ghttp.Request) {
|
||||
r.Response.Write(r.Get("name"), r.Get("score"))
|
||||
|
||||
@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_Context(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.Group("/", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(func(r *ghttp.Request) {
|
||||
|
||||
@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_Cookie(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/set", func(r *ghttp.Request) {
|
||||
r.Cookie.Set(r.GetString("k"), r.GetString("v"))
|
||||
|
||||
@ -24,7 +24,7 @@ import (
|
||||
func Test_Log(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
logDir := gfile.TempDir(gtime.TimestampNanoStr())
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/hello", func(r *ghttp.Request) {
|
||||
r.Response.Write("hello")
|
||||
|
||||
@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_GetUrl(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/url", func(r *ghttp.Request) {
|
||||
r.Response.Write(r.GetUrl())
|
||||
|
||||
@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_BindMiddleware_Basic1(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/test/test", func(r *ghttp.Request) {
|
||||
r.Response.Write("test")
|
||||
@ -60,7 +60,7 @@ func Test_BindMiddleware_Basic1(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_BindMiddleware_Basic2(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/test/test", func(r *ghttp.Request) {
|
||||
r.Response.Write("test")
|
||||
@ -87,7 +87,7 @@ func Test_BindMiddleware_Basic2(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_BindMiddleware_Basic3(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/test/test", func(r *ghttp.Request) {
|
||||
r.Response.Write("test")
|
||||
@ -131,7 +131,7 @@ func Test_BindMiddleware_Basic3(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_BindMiddleware_Basic4(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.Group("/", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(func(r *ghttp.Request) {
|
||||
@ -163,7 +163,7 @@ func Test_BindMiddleware_Basic4(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Middleware_With_Static(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.Group("/", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(func(r *ghttp.Request) {
|
||||
@ -193,7 +193,7 @@ func Test_Middleware_With_Static(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Middleware_Status(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.Group("/", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(func(r *ghttp.Request) {
|
||||
@ -224,7 +224,7 @@ func Test_Middleware_Status(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Middleware_Hook_With_Static(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
a := garray.New(true)
|
||||
s.Group("/", func(group *ghttp.RouterGroup) {
|
||||
@ -278,7 +278,7 @@ func Test_Middleware_Hook_With_Static(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_BindMiddleware_Status(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/test/test", func(r *ghttp.Request) {
|
||||
r.Response.Write("test")
|
||||
@ -304,7 +304,7 @@ func Test_BindMiddleware_Status(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_BindMiddlewareDefault_Basic1(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/test/test", func(r *ghttp.Request) {
|
||||
r.Response.Write("test")
|
||||
@ -335,7 +335,7 @@ func Test_BindMiddlewareDefault_Basic1(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_BindMiddlewareDefault_Basic2(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("PUT:/test/test", func(r *ghttp.Request) {
|
||||
r.Response.Write("test")
|
||||
@ -368,7 +368,7 @@ func Test_BindMiddlewareDefault_Basic2(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_BindMiddlewareDefault_Basic3(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/test/test", func(r *ghttp.Request) {
|
||||
r.Response.Write("test")
|
||||
@ -397,7 +397,7 @@ func Test_BindMiddlewareDefault_Basic3(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_BindMiddlewareDefault_Basic4(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/test/test", func(r *ghttp.Request) {
|
||||
r.Response.Write("test")
|
||||
@ -426,7 +426,7 @@ func Test_BindMiddlewareDefault_Basic4(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_BindMiddlewareDefault_Basic5(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/test/test", func(r *ghttp.Request) {
|
||||
r.Response.Write("test")
|
||||
@ -455,7 +455,7 @@ func Test_BindMiddlewareDefault_Basic5(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_BindMiddlewareDefault_Status(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/test/test", func(r *ghttp.Request) {
|
||||
r.Response.Write("test")
|
||||
@ -501,7 +501,7 @@ func (o *ObjectMiddleware) Info(r *ghttp.Request) {
|
||||
}
|
||||
|
||||
func Test_BindMiddlewareDefault_Basic6(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindObject("/", new(ObjectMiddleware))
|
||||
s.BindMiddlewareDefault(func(r *ghttp.Request) {
|
||||
@ -534,7 +534,7 @@ func Test_BindMiddlewareDefault_Basic6(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Hook_Middleware_Basic1(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/test/test", func(r *ghttp.Request) {
|
||||
r.Response.Write("test")
|
||||
@ -591,7 +591,7 @@ func MiddlewareCORS(r *ghttp.Request) {
|
||||
}
|
||||
|
||||
func Test_Middleware_CORSAndAuth(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.Use(MiddlewareCORS)
|
||||
s.Group("/api.v2", func(group *ghttp.RouterGroup) {
|
||||
@ -645,7 +645,7 @@ func MiddlewareScope3(r *ghttp.Request) {
|
||||
}
|
||||
|
||||
func Test_Middleware_Scope(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.Group("/", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(MiddlewareScope1)
|
||||
@ -682,7 +682,7 @@ func Test_Middleware_Scope(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Middleware_Panic(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
i := 0
|
||||
s.Group("/", func(group *ghttp.RouterGroup) {
|
||||
|
||||
@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_Middleware_CORS1(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.Group("/api.v2", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(MiddlewareCORS)
|
||||
@ -79,7 +79,7 @@ func Test_Middleware_CORS1(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Middleware_CORS2(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.Group("/api.v2", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(MiddlewareCORS)
|
||||
|
||||
@ -22,7 +22,7 @@ import (
|
||||
|
||||
func Test_Params_File_Single(t *testing.T) {
|
||||
dstDirPath := gfile.TempDir(gtime.TimestampNanoStr())
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/upload/single", func(r *ghttp.Request) {
|
||||
file := r.GetUploadFile("file")
|
||||
@ -76,7 +76,7 @@ func Test_Params_File_Single(t *testing.T) {
|
||||
|
||||
func Test_Params_File_CustomName(t *testing.T) {
|
||||
dstDirPath := gfile.TempDir(gtime.TimestampNanoStr())
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/upload/single", func(r *ghttp.Request) {
|
||||
file := r.GetUploadFile("file")
|
||||
@ -113,7 +113,7 @@ func Test_Params_File_CustomName(t *testing.T) {
|
||||
|
||||
func Test_Params_File_Batch(t *testing.T) {
|
||||
dstDirPath := gfile.TempDir(gtime.TimestampNanoStr())
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/upload/batch", func(r *ghttp.Request) {
|
||||
files := r.GetUploadFiles("file")
|
||||
|
||||
@ -25,7 +25,7 @@ func Test_Params_Json_Request(t *testing.T) {
|
||||
Pass1 string `p:"password1"`
|
||||
Pass2 string `p:"password2" v:"required|length:2,20|password3|same:password1#||密码强度不足|两次密码不一致"`
|
||||
}
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/get", func(r *ghttp.Request) {
|
||||
r.Response.WriteExit(r.Get("id"), r.Get("name"))
|
||||
@ -71,7 +71,7 @@ func Test_Params_Json_Response(t *testing.T) {
|
||||
Pass2 string `json:"password2"`
|
||||
}
|
||||
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/json1", func(r *ghttp.Request) {
|
||||
r.Response.WriteJson(User{
|
||||
|
||||
@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_Params_Page(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.Group("/", func(group *ghttp.RouterGroup) {
|
||||
group.GET("/list", func(r *ghttp.Request) {
|
||||
|
||||
@ -26,7 +26,7 @@ func Test_Params_Struct(t *testing.T) {
|
||||
Pass1 string `p:"password1"`
|
||||
Pass2 string `p:"password2" v:"passwd1 @required|length:2,20|password3#||密码强度不足"`
|
||||
}
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/struct1", func(r *ghttp.Request) {
|
||||
if m := r.GetMap(); len(m) > 0 {
|
||||
|
||||
@ -23,7 +23,7 @@ func Test_Params_Basic(t *testing.T) {
|
||||
Pass1 string `params:"password1"`
|
||||
Pass2 string `params:"password2"`
|
||||
}
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
// GET
|
||||
s.BindHandler("/get", func(r *ghttp.Request) {
|
||||
@ -405,7 +405,7 @@ func Test_Params_Basic(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Params_SupportChars(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/form-value", func(r *ghttp.Request) {
|
||||
r.Response.Write(r.GetQuery("test-value"))
|
||||
@ -430,7 +430,7 @@ func Test_Params_SupportChars(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Params_Priority(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/query", func(r *ghttp.Request) {
|
||||
r.Response.Write(r.GetQuery("a"))
|
||||
|
||||
@ -24,7 +24,7 @@ func Test_Params_Xml_Request(t *testing.T) {
|
||||
Pass1 string `p:"password1"`
|
||||
Pass2 string `p:"password2" v:"required|length:2,20|password3|same:password1#||密码强度不足|两次密码不一致"`
|
||||
}
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/get", func(r *ghttp.Request) {
|
||||
r.Response.WriteExit(r.Get("id"), r.Get("name"))
|
||||
|
||||
@ -20,7 +20,7 @@ import (
|
||||
|
||||
func TestServer_EnablePProf(t *testing.T) {
|
||||
C(t, func(t *T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.EnablePProf("/pprof")
|
||||
s.SetDumpRouterMap(false)
|
||||
|
||||
@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_Router_Basic(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/:name", func(r *ghttp.Request) {
|
||||
r.Response.Write("/:name")
|
||||
@ -52,7 +52,7 @@ func Test_Router_Basic(t *testing.T) {
|
||||
|
||||
// HTTP method register.
|
||||
func Test_Router_Method(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("GET:/get", func(r *ghttp.Request) {
|
||||
|
||||
@ -94,7 +94,7 @@ func Test_Router_Method(t *testing.T) {
|
||||
|
||||
// Extra char '/' of the router.
|
||||
func Test_Router_ExtraChar(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.Group("/api", func(group *ghttp.RouterGroup) {
|
||||
group.GET("/test", func(r *ghttp.Request) {
|
||||
@ -119,7 +119,7 @@ func Test_Router_ExtraChar(t *testing.T) {
|
||||
|
||||
// Custom status handler.
|
||||
func Test_Router_Status(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/200", func(r *ghttp.Request) {
|
||||
r.Response.WriteStatus(200)
|
||||
@ -171,7 +171,7 @@ func Test_Router_Status(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_CustomStatusHandler(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/", func(r *ghttp.Request) {
|
||||
r.Response.Write("hello")
|
||||
@ -200,7 +200,7 @@ func Test_Router_CustomStatusHandler(t *testing.T) {
|
||||
|
||||
// 404 not found router.
|
||||
func Test_Router_404(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/", func(r *ghttp.Request) {
|
||||
r.Response.Write("hello")
|
||||
@ -224,7 +224,7 @@ func Test_Router_404(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_Priority(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/admin", func(r *ghttp.Request) {
|
||||
r.Response.Write("admin")
|
||||
|
||||
@ -52,7 +52,7 @@ func (c *ControllerRest) Head() {
|
||||
|
||||
// 控制器注册测试
|
||||
func Test_Router_ControllerRest(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindControllerRest("/", new(ControllerRest))
|
||||
s.BindControllerRest("/{.struct}/{.method}", new(ControllerRest))
|
||||
|
||||
@ -44,7 +44,7 @@ func (c *Controller) Info() {
|
||||
}
|
||||
|
||||
func Test_Router_Controller1(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindController("/", new(Controller))
|
||||
s.BindController("/{.struct}/{.method}", new(Controller))
|
||||
@ -75,7 +75,7 @@ func Test_Router_Controller1(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_Controller2(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindController("/controller", new(Controller), "Show, Info")
|
||||
s.SetPort(p)
|
||||
@ -101,7 +101,7 @@ func Test_Router_Controller2(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_ControllerMethod(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindControllerMethod("/controller-info", new(Controller), "Info")
|
||||
s.SetPort(p)
|
||||
|
||||
@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_Router_DomainBasic(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
d := s.Domain("localhost, local")
|
||||
d.BindHandler("/:name", func(r *ghttp.Request) {
|
||||
@ -69,7 +69,7 @@ func Test_Router_DomainBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_DomainMethod(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
d := s.Domain("localhost, local")
|
||||
d.BindHandler("GET:/get", func(r *ghttp.Request) {
|
||||
@ -161,7 +161,7 @@ func Test_Router_DomainMethod(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_DomainStatus(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
d := s.Domain("localhost, local")
|
||||
d.BindHandler("/200", func(r *ghttp.Request) {
|
||||
@ -257,7 +257,7 @@ func Test_Router_DomainStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_DomainCustomStatusHandler(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
d := s.Domain("localhost, local")
|
||||
d.BindHandler("/", func(r *ghttp.Request) {
|
||||
@ -296,7 +296,7 @@ func Test_Router_DomainCustomStatusHandler(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_Domain404(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
d := s.Domain("localhost, local")
|
||||
d.BindHandler("/", func(r *ghttp.Request) {
|
||||
@ -329,7 +329,7 @@ func Test_Router_Domain404(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_DomainGroup(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
d := s.Domain("localhost, local")
|
||||
d.Group("/", func(group *ghttp.RouterGroup) {
|
||||
|
||||
@ -60,7 +60,7 @@ func (c *DomainControllerRest) Head() {
|
||||
|
||||
// 控制器注册测试
|
||||
func Test_Router_DomainControllerRest(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
d := s.Domain("localhost, local")
|
||||
d.BindControllerRest("/", new(DomainControllerRest))
|
||||
|
||||
@ -43,7 +43,7 @@ func (c *DomainController) Info() {
|
||||
}
|
||||
|
||||
func Test_Router_DomainController1(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.Domain("localhost, local").BindController("/", new(DomainController))
|
||||
s.SetPort(p)
|
||||
@ -93,7 +93,7 @@ func Test_Router_DomainController1(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_DomainController2(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.Domain("localhost, local").BindController("/controller", new(DomainController), "Show, Info")
|
||||
s.SetPort(p)
|
||||
@ -146,7 +146,7 @@ func Test_Router_DomainController2(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_DomainControllerMethod(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.Domain("localhost, local").BindControllerMethod("/controller-info", new(DomainController), "Info")
|
||||
s.SetPort(p)
|
||||
|
||||
@ -55,7 +55,7 @@ func (o *DomainObjectRest) Head(r *ghttp.Request) {
|
||||
}
|
||||
|
||||
func Test_Router_DomainObjectRest(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
d := s.Domain("localhost, local")
|
||||
d.BindObjectRest("/", new(DomainObjectRest))
|
||||
|
||||
@ -39,7 +39,7 @@ func (o *DomainObject) Info(r *ghttp.Request) {
|
||||
}
|
||||
|
||||
func Test_Router_DomainObject1(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.Domain("localhost, local").BindObject("/", new(DomainObject))
|
||||
s.SetPort(p)
|
||||
@ -88,7 +88,7 @@ func Test_Router_DomainObject1(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_DomainObject2(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.Domain("localhost, local").BindObject("/object", new(DomainObject), "Show, Info")
|
||||
s.SetPort(p)
|
||||
@ -139,7 +139,7 @@ func Test_Router_DomainObject2(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_DomainObjectMethod(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.Domain("localhost, local").BindObjectMethod("/object-info", new(DomainObject), "Info")
|
||||
s.SetPort(p)
|
||||
|
||||
@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_Router_Exit(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHookHandlerByMap("/*", map[string]ghttp.HandlerFunc{
|
||||
ghttp.HOOK_BEFORE_SERVE: func(r *ghttp.Request) { r.Response.Write("1") },
|
||||
@ -46,7 +46,7 @@ func Test_Router_Exit(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_ExitHook(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/priority/show", func(r *ghttp.Request) {
|
||||
r.Response.Write("show")
|
||||
@ -84,7 +84,7 @@ func Test_Router_ExitHook(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_ExitAll(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/priority/show", func(r *ghttp.Request) {
|
||||
r.Response.Write("show")
|
||||
|
||||
@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_Router_Group_Group(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.Group("/api.v2", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(func(r *ghttp.Request) {
|
||||
|
||||
@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_Router_Group_Hook1(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
group := s.Group("/api")
|
||||
group.GET("/handler", func(r *ghttp.Request) {
|
||||
@ -46,7 +46,7 @@ func Test_Router_Group_Hook1(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_Group_Hook2(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
g := s.Group("/api")
|
||||
g.GET("/handler", func(r *ghttp.Request) {
|
||||
@ -76,7 +76,7 @@ func Test_Router_Group_Hook2(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_Group_Hook3(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.Group("/api").Bind([]g.Slice{
|
||||
{"ALL", "handler", func(r *ghttp.Request) {
|
||||
|
||||
@ -98,7 +98,7 @@ func (o *GroupObjRest) Head(r *ghttp.Request) {
|
||||
}
|
||||
|
||||
func Test_Router_GroupRest(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
g := s.Group("/api")
|
||||
ctl := new(GroupCtlRest)
|
||||
|
||||
@ -71,7 +71,7 @@ func Handler(r *ghttp.Request) {
|
||||
}
|
||||
|
||||
func Test_Router_GroupBasic1(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
obj := new(GroupObject)
|
||||
ctl := new(GroupController)
|
||||
@ -118,7 +118,7 @@ func Test_Router_GroupBasic1(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_GroupBasic2(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
obj := new(GroupObject)
|
||||
ctl := new(GroupController)
|
||||
@ -160,7 +160,7 @@ func Test_Router_GroupBasic2(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_GroupBuildInVar(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
obj := new(GroupObject)
|
||||
ctl := new(GroupController)
|
||||
@ -192,7 +192,7 @@ func Test_Router_GroupBuildInVar(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_Group_Mthods(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
obj := new(GroupObject)
|
||||
ctl := new(GroupController)
|
||||
|
||||
@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_Router_Hook_Basic(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHookHandlerByMap("/*", map[string]ghttp.HandlerFunc{
|
||||
ghttp.HOOK_BEFORE_SERVE: func(r *ghttp.Request) { r.Response.Write("1") },
|
||||
@ -44,7 +44,7 @@ func Test_Router_Hook_Basic(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_Hook_Fuzzy_Router(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
i := 1000
|
||||
pattern1 := "/:name/info"
|
||||
@ -88,7 +88,7 @@ func Test_Router_Hook_Fuzzy_Router(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_Hook_Priority(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/priority/show", func(r *ghttp.Request) {
|
||||
r.Response.Write("show")
|
||||
@ -127,7 +127,7 @@ func Test_Router_Hook_Priority(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_Hook_Multi(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/multi-hook", func(r *ghttp.Request) {
|
||||
r.Response.Write("show")
|
||||
|
||||
@ -23,7 +23,7 @@ func (o *NamesObject) ShowName(r *ghttp.Request) {
|
||||
}
|
||||
|
||||
func Test_NameToUri_FullName(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.SetNameToUriType(ghttp.URI_TYPE_FULLNAME)
|
||||
s.BindObject("/{.struct}/{.method}", new(NamesObject))
|
||||
@ -44,7 +44,7 @@ func Test_NameToUri_FullName(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_NameToUri_AllLower(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.SetNameToUriType(ghttp.URI_TYPE_ALLLOWER)
|
||||
s.BindObject("/{.struct}/{.method}", new(NamesObject))
|
||||
@ -65,7 +65,7 @@ func Test_NameToUri_AllLower(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_NameToUri_Camel(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.SetNameToUriType(ghttp.URI_TYPE_CAMEL)
|
||||
s.BindObject("/{.struct}/{.method}", new(NamesObject))
|
||||
@ -86,7 +86,7 @@ func Test_NameToUri_Camel(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_NameToUri_Default(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.SetNameToUriType(ghttp.URI_TYPE_DEFAULT)
|
||||
s.BindObject("/{.struct}/{.method}", new(NamesObject))
|
||||
|
||||
@ -55,7 +55,7 @@ func (o *ObjectRest) Head(r *ghttp.Request) {
|
||||
}
|
||||
|
||||
func Test_Router_ObjectRest(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindObjectRest("/", new(ObjectRest))
|
||||
s.BindObjectRest("/{.struct}/{.method}", new(ObjectRest))
|
||||
|
||||
@ -43,7 +43,7 @@ func (o *ObjectRest2) Delete(r *ghttp.Request) {
|
||||
}
|
||||
|
||||
func Test_Router_ObjectRest_Id(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindObjectRest("/object/:id", new(ObjectRest2))
|
||||
s.SetPort(p)
|
||||
|
||||
@ -39,7 +39,7 @@ func (o *Object) Info(r *ghttp.Request) {
|
||||
}
|
||||
|
||||
func Test_Router_Object1(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindObject("/", new(Object))
|
||||
s.BindObject("/{.struct}/{.method}", new(Object))
|
||||
@ -70,7 +70,7 @@ func Test_Router_Object1(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_Object2(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindObject("/object", new(Object), "Show, Info")
|
||||
s.SetPort(p)
|
||||
@ -96,7 +96,7 @@ func Test_Router_Object2(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Router_ObjectMethod(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindObjectMethod("/object-info", new(Object), "Info")
|
||||
s.SetPort(p)
|
||||
|
||||
@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_Session_Cookie(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/set", func(r *ghttp.Request) {
|
||||
r.Session.Set(r.GetString("k"), r.GetString("v"))
|
||||
@ -64,7 +64,7 @@ func Test_Session_Cookie(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Session_Header(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/set", func(r *ghttp.Request) {
|
||||
r.Session.Set(r.GetString("k"), r.GetString("v"))
|
||||
@ -115,7 +115,7 @@ func Test_Session_Header(t *testing.T) {
|
||||
|
||||
func Test_Session_StorageFile(t *testing.T) {
|
||||
sessionId := ""
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/set", func(r *ghttp.Request) {
|
||||
r.Session.Set(r.GetString("k"), r.GetString("v"))
|
||||
|
||||
@ -25,7 +25,7 @@ import (
|
||||
func Test_Static_ServerRoot(t *testing.T) {
|
||||
// SetServerRoot with absolute path
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
path := fmt.Sprintf(`%s/ghttp/static/test/%d`, gfile.TempDir(), p)
|
||||
defer gfile.Remove(path)
|
||||
@ -44,7 +44,7 @@ func Test_Static_ServerRoot(t *testing.T) {
|
||||
|
||||
// SetServerRoot with relative path
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
path := fmt.Sprintf(`static/test/%d`, p)
|
||||
defer gfile.Remove(path)
|
||||
@ -64,7 +64,7 @@ func Test_Static_ServerRoot(t *testing.T) {
|
||||
|
||||
func Test_Static_ServerRoot_Security(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.SetServerRoot(gdebug.TestDataPath("static1"))
|
||||
s.SetPort(p)
|
||||
@ -85,7 +85,7 @@ func Test_Static_ServerRoot_Security(t *testing.T) {
|
||||
|
||||
func Test_Static_Folder_Forbidden(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
path := fmt.Sprintf(`%s/ghttp/static/test/%d`, gfile.TempDir(), p)
|
||||
defer gfile.Remove(path)
|
||||
@ -106,7 +106,7 @@ func Test_Static_Folder_Forbidden(t *testing.T) {
|
||||
|
||||
func Test_Static_IndexFolder(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
path := fmt.Sprintf(`%s/ghttp/static/test/%d`, gfile.TempDir(), p)
|
||||
defer gfile.Remove(path)
|
||||
@ -129,7 +129,7 @@ func Test_Static_IndexFolder(t *testing.T) {
|
||||
|
||||
func Test_Static_IndexFiles1(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
path := fmt.Sprintf(`%s/ghttp/static/test/%d`, gfile.TempDir(), p)
|
||||
defer gfile.Remove(path)
|
||||
@ -151,7 +151,7 @@ func Test_Static_IndexFiles1(t *testing.T) {
|
||||
|
||||
func Test_Static_IndexFiles2(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
path := fmt.Sprintf(`%s/ghttp/static/test/%d`, gfile.TempDir(), p)
|
||||
defer gfile.Remove(path)
|
||||
@ -173,7 +173,7 @@ func Test_Static_IndexFiles2(t *testing.T) {
|
||||
|
||||
func Test_Static_AddSearchPath1(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
path1 := fmt.Sprintf(`%s/ghttp/static/test/%d`, gfile.TempDir(), p)
|
||||
path2 := fmt.Sprintf(`%s/ghttp/static/test/%d/%d`, gfile.TempDir(), p, p)
|
||||
@ -196,7 +196,7 @@ func Test_Static_AddSearchPath1(t *testing.T) {
|
||||
|
||||
func Test_Static_AddSearchPath2(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
path1 := fmt.Sprintf(`%s/ghttp/static/test/%d`, gfile.TempDir(), p)
|
||||
path2 := fmt.Sprintf(`%s/ghttp/static/test/%d/%d`, gfile.TempDir(), p, p)
|
||||
@ -220,7 +220,7 @@ func Test_Static_AddSearchPath2(t *testing.T) {
|
||||
|
||||
func Test_Static_AddStaticPath(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
path1 := fmt.Sprintf(`%s/ghttp/static/test/%d`, gfile.TempDir(), p)
|
||||
path2 := fmt.Sprintf(`%s/ghttp/static/test/%d/%d`, gfile.TempDir(), p, p)
|
||||
@ -245,7 +245,7 @@ func Test_Static_AddStaticPath(t *testing.T) {
|
||||
|
||||
func Test_Static_AddStaticPath_Priority(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
path1 := fmt.Sprintf(`%s/ghttp/static/test/%d/test`, gfile.TempDir(), p)
|
||||
path2 := fmt.Sprintf(`%s/ghttp/static/test/%d/%d/test`, gfile.TempDir(), p, p)
|
||||
@ -270,7 +270,7 @@ func Test_Static_AddStaticPath_Priority(t *testing.T) {
|
||||
|
||||
func Test_Static_Rewrite(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
path := fmt.Sprintf(`%s/ghttp/static/test/%d`, gfile.TempDir(), p)
|
||||
defer gfile.Remove(path)
|
||||
|
||||
@ -24,7 +24,7 @@ import (
|
||||
func Test_Template_Basic(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
v := gview.New(gdebug.TestDataPath("template", "basic"))
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.SetView(v)
|
||||
s.BindHandler("/", func(r *ghttp.Request) {
|
||||
@ -50,7 +50,7 @@ func Test_Template_Encode(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
v := gview.New(gdebug.TestDataPath("template", "basic"))
|
||||
v.SetAutoEncode(true)
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.SetView(v)
|
||||
s.BindHandler("/", func(r *ghttp.Request) {
|
||||
@ -75,7 +75,7 @@ func Test_Template_Encode(t *testing.T) {
|
||||
func Test_Template_Layout1(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
v := gview.New(gdebug.TestDataPath("template", "layout1"))
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.SetView(v)
|
||||
s.BindHandler("/layout", func(r *ghttp.Request) {
|
||||
@ -105,7 +105,7 @@ func Test_Template_Layout1(t *testing.T) {
|
||||
func Test_Template_Layout2(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
v := gview.New(gdebug.TestDataPath("template", "layout2"))
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.SetView(v)
|
||||
s.BindHandler("/main1", func(r *ghttp.Request) {
|
||||
@ -144,7 +144,7 @@ func Test_Template_XSS(t *testing.T) {
|
||||
v := gview.New()
|
||||
v.SetAutoEncode(true)
|
||||
c := "<br>"
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.SetView(v)
|
||||
s.BindHandler("/", func(r *ghttp.Request) {
|
||||
|
||||
@ -19,7 +19,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_WebSocket(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := g.Server(p)
|
||||
s.BindHandler("/ws", func(r *ghttp.Request) {
|
||||
ws, err := r.WebSocket()
|
||||
|
||||
@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_Package_Basic(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := gtcp.NewServer(fmt.Sprintf(`:%d`, p), func(conn *gtcp.Conn) {
|
||||
defer conn.Close()
|
||||
for {
|
||||
@ -96,7 +96,7 @@ func Test_Package_Basic(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Package_Timeout(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := gtcp.NewServer(fmt.Sprintf(`:%d`, p), func(conn *gtcp.Conn) {
|
||||
defer conn.Close()
|
||||
for {
|
||||
@ -132,7 +132,7 @@ func Test_Package_Timeout(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Package_Option(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := gtcp.NewServer(fmt.Sprintf(`:%d`, p), func(conn *gtcp.Conn) {
|
||||
defer conn.Close()
|
||||
option := gtcp.PkgOption{HeaderSize: 1}
|
||||
|
||||
@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_Pool_Package_Basic(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := gtcp.NewServer(fmt.Sprintf(`:%d`, p), func(conn *gtcp.Conn) {
|
||||
defer conn.Close()
|
||||
for {
|
||||
@ -96,7 +96,7 @@ func Test_Pool_Package_Basic(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Pool_Package_Timeout(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := gtcp.NewServer(fmt.Sprintf(`:%d`, p), func(conn *gtcp.Conn) {
|
||||
defer conn.Close()
|
||||
for {
|
||||
@ -132,7 +132,7 @@ func Test_Pool_Package_Timeout(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Pool_Package_Option(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := gtcp.NewServer(fmt.Sprintf(`:%d`, p), func(conn *gtcp.Conn) {
|
||||
defer conn.Close()
|
||||
option := gtcp.PkgOption{HeaderSize: 1}
|
||||
|
||||
@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_Pool_Basic1(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := gtcp.NewServer(fmt.Sprintf(`:%d`, p), func(conn *gtcp.Conn) {
|
||||
defer conn.Close()
|
||||
for {
|
||||
@ -42,7 +42,7 @@ func Test_Pool_Basic1(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Pool_Basic2(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := gtcp.NewServer(fmt.Sprintf(`:%d`, p), func(conn *gtcp.Conn) {
|
||||
conn.Close()
|
||||
})
|
||||
|
||||
@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_Basic(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := gudp.NewServer(fmt.Sprintf("127.0.0.1:%d", p), func(conn *gudp.Conn) {
|
||||
defer conn.Close()
|
||||
for {
|
||||
@ -75,7 +75,7 @@ func Test_Basic(t *testing.T) {
|
||||
// If the read buffer size is less than the sent package size,
|
||||
// the rest data would be dropped.
|
||||
func Test_Buffer(t *testing.T) {
|
||||
p := ports.PopRand()
|
||||
p, _ := ports.PopRand()
|
||||
s := gudp.NewServer(fmt.Sprintf("127.0.0.1:%d", p), func(conn *gudp.Conn) {
|
||||
defer conn.Close()
|
||||
for {
|
||||
|
||||
Reference in New Issue
Block a user