From 1c1f9be66f76c19fc8f12ce1547ff0f69a052a03 Mon Sep 17 00:00:00 2001 From: giongto35 Date: Wed, 24 Apr 2019 02:48:48 +0800 Subject: [PATCH] Assert --- main_test.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/main_test.go b/main_test.go index fdc91654..8d03f0da 100644 --- a/main_test.go +++ b/main_test.go @@ -90,6 +90,8 @@ func initClient(t *testing.T, host string) { time.Sleep(time.Second * 3) fmt.Println("Sending start...") + + roomID := make(chan string) client.send(WSPacket{ ID: "start", Data: "Contra.nes", @@ -98,12 +100,27 @@ func initClient(t *testing.T, host string) { }, func(resp WSPacket) { fmt.Println("Received response") fmt.Println("RoomID:", resp.RoomID) + roomID <- resp.RoomID }) - time.Sleep(time.Hour) + respRoomID := <-roomID + if respRoomID == "" { + fmt.Println("RoomID should not be empty") + t.Fail() + } + fmt.Println("Done") + // If receive roomID, the server is running correctly } -func TestMain(t *testing.T) { +//func TestSingleServerNoOverlord(t *testing.T) { +//// Init slave server +//s := initServer(t, "") +//defer s.Close() + +//initClient(t, s.URL) +//} + +func TestSingleServerOneOverlord(t *testing.T) { o := initOverlord() defer o.Close() // Init slave server