From 0c53f10fd72d6f16319eea1ef721dd83a634ba15 Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Fri, 23 Apr 2021 15:26:05 +0200 Subject: [PATCH] No need to manually close rooms in testing, will be done by hub on client disconnects. --- backend_server_test.go | 25 ------------------------- hub_test.go | 35 +---------------------------------- room_test.go | 4 ---- 3 files changed, 1 insertion(+), 63 deletions(-) diff --git a/backend_server_test.go b/backend_server_test.go index 90b5548..9ba3d02 100644 --- a/backend_server_test.go +++ b/backend_server_test.go @@ -406,10 +406,6 @@ func TestBackendServer_RoomDisinvite(t *testing.T) { t.Fatalf("Expected room %s, got %s", roomId, room.Room.RoomId) } - if hubRoom := hub.getRoom(roomId); hubRoom != nil { - defer hubRoom.Close() - } - // Ignore "join" events. if err := client.DrainMessages(ctx); err != nil { t.Error(err) @@ -518,12 +514,6 @@ func TestBackendServer_RoomDisinviteDifferentRooms(t *testing.T) { if _, err := client2.JoinRoom(ctx, roomId2); err != nil { t.Fatal(err) } - if hubRoom := hub.getRoom(roomId1); hubRoom != nil { - defer hubRoom.Close() - } - if hubRoom := hub.getRoom(roomId2); hubRoom != nil { - defer hubRoom.Close() - } // Ignore "join" events. if err := client1.DrainMessages(ctx); err != nil { @@ -830,10 +820,6 @@ func TestBackendServer_ParticipantsUpdatePermissions(t *testing.T) { t.Fatalf("Expected room %s, got %s", roomId, room.Room.RoomId) } - if hubRoom := hub.getRoom(roomId); hubRoom != nil { - defer hubRoom.Close() - } - // Ignore "join" events. if err := client1.DrainMessages(ctx); err != nil { t.Error(err) @@ -927,9 +913,6 @@ func TestBackendServer_ParticipantsUpdateEmptyPermissions(t *testing.T) { if err != nil { t.Fatal(err) } - if hubRoom := hub.getRoom(room.Room.RoomId); hubRoom != nil { - defer hubRoom.Close() - } if room.Room.RoomId != roomId { t.Fatalf("Expected room %s, got %s", roomId, room.Room.RoomId) } @@ -1027,10 +1010,6 @@ func TestBackendServer_ParticipantsUpdateTimeout(t *testing.T) { t.Fatalf("Expected room %s, got %s", roomId, room.Room.RoomId) } - if hubRoom := hub.getRoom(roomId); hubRoom != nil { - defer hubRoom.Close() - } - WaitForUsersJoined(ctx, t, client1, hello1, client2, hello2) var wg sync.WaitGroup @@ -1227,10 +1206,6 @@ func TestBackendServer_RoomMessage(t *testing.T) { t.Fatalf("Expected room %s, got %s", roomId, room.Room.RoomId) } - if hubRoom := hub.getRoom(roomId); hubRoom != nil { - defer hubRoom.Close() - } - // Ignore "join" events. if err := client.DrainMessages(ctx); err != nil { t.Error(err) diff --git a/hub_test.go b/hub_test.go index 85c800f..b3ccc87 100644 --- a/hub_test.go +++ b/hub_test.go @@ -1125,9 +1125,6 @@ func TestClientHelloResumeAndJoin(t *testing.T) { } else if room.Room.RoomId != roomId { t.Fatalf("Expected room %s, got %s", roomId, room.Room.RoomId) } - if hubRoom := hub.getRoom(roomId); hubRoom != nil { - defer hubRoom.Close() - } } func TestClientHelloClient(t *testing.T) { @@ -1480,10 +1477,6 @@ func TestClientMessageToRoom(t *testing.T) { t.Fatalf("Expected room %s, got %s", roomId, room.Room.RoomId) } - if hubRoom := hub.getRoom(roomId); hubRoom != nil { - defer hubRoom.Close() - } - WaitForUsersJoined(ctx, t, client1, hello1, client2, hello2) recipient := MessageClientMessageRecipient{ @@ -1536,10 +1529,6 @@ func TestJoinRoom(t *testing.T) { t.Fatalf("Expected room %s, got %s", roomId, room.Room.RoomId) } - if hubRoom := hub.getRoom(roomId); hubRoom != nil { - defer hubRoom.Close() - } - // We will receive a "joined" event. if err := client.RunUntilJoined(ctx, hello.Hello); err != nil { t.Error(err) @@ -1633,10 +1622,6 @@ func TestJoinRoomChange(t *testing.T) { t.Fatalf("Expected room %s, got %s", roomId, room.Room.RoomId) } - if hubRoom := hub.getRoom(roomId); hubRoom != nil { - defer hubRoom.Close() - } - // We will receive a "joined" event. if err := client.RunUntilJoined(ctx, hello.Hello); err != nil { t.Error(err) @@ -1650,10 +1635,6 @@ func TestJoinRoomChange(t *testing.T) { t.Fatalf("Expected room %s, got %s", roomId, room.Room.RoomId) } - if hubRoom := hub.getRoom(roomId); hubRoom != nil { - defer hubRoom.Close() - } - // We will receive a "joined" event. if err := client.RunUntilJoined(ctx, hello.Hello); err != nil { t.Error(err) @@ -1706,10 +1687,6 @@ func TestJoinMultiple(t *testing.T) { t.Fatalf("Expected room %s, got %s", roomId, room.Room.RoomId) } - if hubRoom := hub.getRoom(roomId); hubRoom != nil { - defer hubRoom.Close() - } - // We will receive a "joined" event. if err := client1.RunUntilJoined(ctx, hello1.Hello); err != nil { t.Error(err) @@ -1928,10 +1905,6 @@ func TestRoomParticipantsListUpdateWhileDisconnected(t *testing.T) { t.Fatalf("Expected room %s, got %s", roomId, room.Room.RoomId) } - if hubRoom := hub.getRoom(roomId); hubRoom != nil { - defer hubRoom.Close() - } - WaitForUsersJoined(ctx, t, client1, hello1, client2, hello2) // Simulate request from the backend that somebody joined the call. @@ -2045,9 +2018,7 @@ func TestClientTakeoverRoomSession(t *testing.T) { t.Fatalf("Expected room %s, got %s", roomId, room.Room.RoomId) } - if hubRoom := hub.getRoom(roomId); hubRoom != nil { - defer hubRoom.Close() - } else { + if hubRoom := hub.getRoom(roomId); hubRoom == nil { t.Fatalf("Room %s does not exist", roomId) } @@ -2207,10 +2178,6 @@ func TestClientSendOfferPermissions(t *testing.T) { t.Fatalf("Expected room %s, got %s", roomId, room.Room.RoomId) } - if hubRoom := hub.getRoom(roomId); hubRoom != nil { - defer hubRoom.Close() - } - WaitForUsersJoined(ctx, t, client1, hello1, client2, hello2) session1 := hub.GetSessionByPublicId(hello1.Hello.SessionId).(*ClientSession) diff --git a/room_test.go b/room_test.go index a5cc544..62fbb5e 100644 --- a/room_test.go +++ b/room_test.go @@ -110,10 +110,6 @@ func TestRoom_Update(t *testing.T) { t.Fatalf("Expected room %s, got %s", roomId, room.Room.RoomId) } - if hubRoom := hub.getRoom(roomId); hubRoom != nil { - defer hubRoom.Close() - } - // We will receive a "joined" event. if err := client.RunUntilJoined(ctx, hello.Hello); err != nil { t.Error(err)