add one unit testing case for ghttp.Server
@@ -469,3 +469,30 @@ func Test_Params_Priority(t *testing.T) {
t.Assert(client.GetContent("/request-map?a=1&b=2&c=3", "a=100&b=200&c=300"), `{"a":"100","b":"200"}`)
})
}
+
+func Test_Params_GetRequestMap(t *testing.T) {
+ p, _ := ports.PopRand()
+ s := g.Server(p)
+ s.BindHandler("/map", func(r *ghttp.Request) {
+ r.Response.Write(r.GetRequestMap())
+ })
+ s.SetPort(p)
+ s.SetDumpRouterMap(false)
+ s.Start()
+ defer s.Shutdown()
+
+ time.Sleep(100 * time.Millisecond)
+ gtest.C(t, func(t *gtest.T) {
+ prefix := fmt.Sprintf("http://127.0.0.1:%d", p)
+ client := ghttp.NewClient()
+ client.SetPrefix(prefix)
+
+ t.Assert(
+ client.PostContent(
+ "/map",
+ "time_end2020-04-18 16:11:58&returnmsg=Success&attach=",
+ ),
+ `{"attach":"","returnmsg":"Success"}`,
+ )
+ })
+}
