mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-25 19:13:52 +00:00
Update test rejoin with overlord
This commit is contained in:
parent
2b37360b2e
commit
d7cdf02cb7
1 changed files with 46 additions and 1 deletions
|
|
@ -459,7 +459,7 @@ func TestReconnectRoomWithOverlord(t *testing.T) {
|
|||
func TestRejoinNoOverlordMultiple(t *testing.T) {
|
||||
/*
|
||||
Case scenario:
|
||||
- A server X is initialized connecting to overlord
|
||||
- A server X without connecting to overlord
|
||||
- Client A keeps creating a new room
|
||||
Expected behavior:
|
||||
- The game should running normally
|
||||
|
|
@ -495,3 +495,48 @@ func TestRejoinNoOverlordMultiple(t *testing.T) {
|
|||
fmt.Println("Done")
|
||||
|
||||
}
|
||||
|
||||
func TestRejoinWithOverlordMultiple(t *testing.T) {
|
||||
/*
|
||||
Case scenario:
|
||||
- A server X is initialized connecting to overlord
|
||||
- Client A keeps creating a new room
|
||||
Expected behavior:
|
||||
- The game should running normally
|
||||
*/
|
||||
|
||||
// Init slave server
|
||||
o := initOverlord()
|
||||
defer o.Close()
|
||||
|
||||
oconn := connectTestOverlordServer(t, o.URL)
|
||||
// Init slave server
|
||||
s := initServer(t, oconn)
|
||||
defer s.Close()
|
||||
|
||||
fmt.Println("Num goRoutine before start: ", runtime.NumGoroutine())
|
||||
client := initClient(t, s.URL)
|
||||
for i := 0; i < 100; i++ {
|
||||
fmt.Println("Sending start...")
|
||||
// Keep starting game
|
||||
roomID := make(chan string)
|
||||
client.Send(cws.WSPacket{
|
||||
ID: "start",
|
||||
Data: "Contra.nes",
|
||||
RoomID: "",
|
||||
PlayerIndex: 1,
|
||||
}, func(resp cws.WSPacket) {
|
||||
fmt.Println("RoomID:", resp.RoomID)
|
||||
roomID <- resp.RoomID
|
||||
})
|
||||
|
||||
respRoomID := <-roomID
|
||||
if respRoomID == "" {
|
||||
fmt.Println("The room ID should be equal to the saved room")
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
fmt.Println("Num goRoutine should be small: ", runtime.NumGoroutine())
|
||||
fmt.Println("Done")
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue