From 3bff71b3fc412a898807a75ca9d9fa0573a18bfe Mon Sep 17 00:00:00 2001 From: yuzhan Date: Wed, 2 Mar 2022 15:33:58 +0800 Subject: [PATCH] merge master and update unit test --- net/ghttp/ghttp_z_unit_feature_cookie_test.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/net/ghttp/ghttp_z_unit_feature_cookie_test.go b/net/ghttp/ghttp_z_unit_feature_cookie_test.go index 4271165cb89..b6aa8fa8cf2 100644 --- a/net/ghttp/ghttp_z_unit_feature_cookie_test.go +++ b/net/ghttp/ghttp_z_unit_feature_cookie_test.go @@ -104,12 +104,10 @@ func Test_SetHttpCookie(t *testing.T) { } func Test_CookieOptionsDefault(t *testing.T) { - p, _ := ports.PopRand() - s := g.Server(p) + s := g.Server(guid.S()) s.BindHandler("/test", func(r *ghttp.Request) { r.Cookie.Set(r.Get("k").String(), r.Get("v").String()) }) - s.SetPort(p) s.SetDumpRouterMap(false) s.Start() defer s.Shutdown() @@ -118,7 +116,7 @@ func Test_CookieOptionsDefault(t *testing.T) { gtest.C(t, func(t *gtest.T) { client := g.Client() client.SetBrowserMode(true) - client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", p)) + client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) r1, e1 := client.Get(ctx, "/test?k=key1&v=100") if r1 != nil { defer r1.Close() @@ -134,8 +132,7 @@ func Test_CookieOptionsDefault(t *testing.T) { } func Test_CookieOptions(t *testing.T) { - p, _ := ports.PopRand() - s := g.Server(p) + s := g.Server(guid.S()) s.SetConfigWithMap(g.Map{ "cookieSameSite": "lax", "cookieSecure": true, @@ -144,7 +141,6 @@ func Test_CookieOptions(t *testing.T) { s.BindHandler("/test", func(r *ghttp.Request) { r.Cookie.Set(r.Get("k").String(), r.Get("v").String()) }) - s.SetPort(p) s.SetDumpRouterMap(false) s.Start() defer s.Shutdown() @@ -153,7 +149,7 @@ func Test_CookieOptions(t *testing.T) { gtest.C(t, func(t *gtest.T) { client := g.Client() client.SetBrowserMode(true) - client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", p)) + client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) r1, e1 := client.Get(ctx, "/test?k=key1&v=100") if r1 != nil { defer r1.Close()