You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ti...@apache.org on 2021/05/21 06:55:08 UTC
[servicecomb-service-center] branch v1.x updated: SCB-2176 Fix: UT
panic (#998)
This is an automated email from the ASF dual-hosted git repository.
tianxiaoliang pushed a commit to branch v1.x
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git
The following commit(s) were added to refs/heads/v1.x by this push:
new aea80c2 SCB-2176 Fix: UT panic (#998)
aea80c2 is described below
commit aea80c23f3ba0d6d8599b16537198e0605bf9b36
Author: little-cui <su...@qq.com>
AuthorDate: Fri May 21 14:55:00 2021 +0800
SCB-2176 Fix: UT panic (#998)
---
server/connection/ws/websocket_test.go | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/server/connection/ws/websocket_test.go b/server/connection/ws/websocket_test.go
index 7518b5a..cd4ad8b 100644
--- a/server/connection/ws/websocket_test.go
+++ b/server/connection/ws/websocket_test.go
@@ -41,14 +41,17 @@ func init() {
}
type watcherConn struct {
+ MockServer *httptest.Server
ClientConn *websocket.Conn
ServerConn *websocket.Conn
}
func (h *watcherConn) Test() {
- s := httptest.NewServer(h)
+ h.MockServer = httptest.NewServer(h)
h.ClientConn, _, _ = websocket.DefaultDialer.Dial(
- strings.Replace(s.URL, "http://", "ws://", 1), nil)
+ strings.Replace(h.MockServer.URL, "http://", "ws://", 1), nil)
+ // wait server is ready
+ <-time.After(time.Second)
}
func (h *watcherConn) ServeHTTP(w http.ResponseWriter, r *http.Request) {
@@ -66,6 +69,7 @@ func (h *watcherConn) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h.ServerConn.Close()
return
}
+ h.MockServer.Close()
}
func NewTest() *watcherConn {