Skip to content

Commit

Permalink
merge master and update unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyingBlazer committed Mar 2, 2022
1 parent 8343d1c commit 3bff71b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions net/ghttp/ghttp_z_unit_feature_cookie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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,
Expand All @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 3bff71b

Please sign in to comment.