mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-22 17:47:11 +00:00
Update test for Single server no overlord
This commit is contained in:
parent
c6c95f339d
commit
f21d357cd8
1 changed files with 13 additions and 6 deletions
19
main_test.go
19
main_test.go
|
|
@ -22,14 +22,18 @@ func initOverlord() *httptest.Server {
|
|||
}
|
||||
|
||||
func initServer(t *testing.T, overlordURL string) *httptest.Server {
|
||||
u := "ws" + strings.TrimPrefix(overlordURL, "http")
|
||||
fmt.Println("connecting to overlord: ", u)
|
||||
if overlordURL == "" {
|
||||
oclient = nil
|
||||
} else {
|
||||
u := "ws" + strings.TrimPrefix(overlordURL, "http")
|
||||
fmt.Println("connecting to overlord: ", u)
|
||||
|
||||
oconn, _, err := websocket.DefaultDialer.Dial(u, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
oconn, _, err := websocket.DefaultDialer.Dial(u, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
}
|
||||
oclient = NewOverlordClient(oconn)
|
||||
}
|
||||
oclient = NewOverlordClient(oconn)
|
||||
|
||||
server := httptest.NewServer(http.HandlerFunc(ws))
|
||||
return server
|
||||
|
|
@ -109,11 +113,13 @@ func initClient(t *testing.T, host string) {
|
|||
t.Fail()
|
||||
}
|
||||
fmt.Println("Done")
|
||||
ws.Close()
|
||||
// If receive roomID, the server is running correctly
|
||||
}
|
||||
|
||||
//func TestSingleServerNoOverlord(t *testing.T) {
|
||||
//// Init slave server
|
||||
//oclient = nil
|
||||
//s := initServer(t, "")
|
||||
//defer s.Close()
|
||||
|
||||
|
|
@ -128,4 +134,5 @@ func TestSingleServerOneOverlord(t *testing.T) {
|
|||
defer s.Close()
|
||||
|
||||
initClient(t, s.URL)
|
||||
oclient.conn.Close()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue