Skip to content

Commit 0894956

Browse files
committed
test: add timout to let the server bind
1 parent b47dd3d commit 0894956

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

websocketproxy_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import (
55
"net/http"
66
"net/url"
77
"testing"
8+
"time"
89

910
"github.com/gorilla/websocket"
1011
)
1112

1213
var (
13-
serverURL = "ws://localhost:7777"
14+
serverURL = "ws://127.0.0.1:7777"
1415
backendURL = "ws://127.0.0.1:8888"
1516
)
1617

@@ -29,6 +30,8 @@ func TestProxy(t *testing.T) {
2930
}
3031
}()
3132

33+
time.Sleep(time.Millisecond * 100)
34+
3235
// backend echo server
3336
go func() {
3437
mux2 := http.NewServeMux()
@@ -53,9 +56,10 @@ func TestProxy(t *testing.T) {
5356
if err != nil {
5457
t.Fatal("ListenAndServe: ", err)
5558
}
56-
5759
}()
5860

61+
time.Sleep(time.Millisecond * 100)
62+
5963
// frontend server, dial now our proxy, which will reverse proxy our
6064
// message to the backend websocket server.
6165
conn, _, err := websocket.DefaultDialer.Dial(serverURL+"/proxy", nil)

0 commit comments

Comments
 (0)