From 1736e71e6bd55dcc9d4ed6da1159a5322c9a3204 Mon Sep 17 00:00:00 2001 From: John Date: Sun, 13 Oct 2019 22:40:23 +0800 Subject: [PATCH] add debug for unit test case of --- net/ghttp/ghttp_unit_middleware_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/net/ghttp/ghttp_unit_middleware_test.go b/net/ghttp/ghttp_unit_middleware_test.go index 2c568c278..3eaa09419 100644 --- a/net/ghttp/ghttp_unit_middleware_test.go +++ b/net/ghttp/ghttp_unit_middleware_test.go @@ -222,7 +222,7 @@ func Test_Middleware_Hook_With_Static(t *testing.T) { }) }) s.SetPort(p) - s.SetDumpRouteMap(false) + //s.SetDumpRouteMap(false) s.SetServerRoot(gfile.Join(gdebug.CallerDirectory(), "testdata", "static1")) s.Start() defer s.Shutdown() @@ -231,13 +231,22 @@ func Test_Middleware_Hook_With_Static(t *testing.T) { client := ghttp.NewClient() client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", p)) + // The length assert sometimes fails, so I added time.Sleep here for debug purpose. + gtest.Assert(client.GetContent("/"), "index") + time.Sleep(100 * time.Millisecond) gtest.Assert(a.Len(), 2) + gtest.Assert(client.GetContent("/test.html"), "test") + time.Sleep(100 * time.Millisecond) gtest.Assert(a.Len(), 4) + gtest.Assert(client.GetContent("/none"), "a12b") + time.Sleep(100 * time.Millisecond) gtest.Assert(a.Len(), 6) + gtest.Assert(client.GetContent("/user/list"), "a1list2b") + time.Sleep(100 * time.Millisecond) gtest.Assert(a.Len(), 8) }) }