mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2026-03-14 14:35:44 +01:00
Ensure all client connections are closed when test ends.
This commit is contained in:
parent
adb391ab5a
commit
16c37cb0ed
4 changed files with 28 additions and 1 deletions
|
|
@ -483,6 +483,7 @@ func RunTestBackendServer_RoomDisinvite(ctx context.Context, t *testing.T) {
|
|||
defer cancel()
|
||||
|
||||
client, hello := NewTestClientWithHello(ctx, t, server, hub, testDefaultUserId)
|
||||
defer client.CloseWithBye()
|
||||
|
||||
// Join room by id.
|
||||
roomId := "test-room"
|
||||
|
|
@ -550,7 +551,9 @@ func TestBackendServer_RoomDisinviteDifferentRooms(t *testing.T) {
|
|||
defer cancel()
|
||||
|
||||
client1, hello1 := NewTestClientWithHello(ctx, t, server, hub, testDefaultUserId)
|
||||
defer client1.CloseWithBye()
|
||||
client2, hello2 := NewTestClientWithHello(ctx, t, server, hub, testDefaultUserId)
|
||||
defer client2.CloseWithBye()
|
||||
|
||||
// Join room by id.
|
||||
roomId1 := "test-room1"
|
||||
|
|
@ -780,7 +783,9 @@ func TestBackendServer_ParticipantsUpdatePermissions(t *testing.T) {
|
|||
defer cancel()
|
||||
|
||||
client1, hello1 := NewTestClientWithHello(ctx, t, server1, hub1, testDefaultUserId+"1")
|
||||
defer client1.CloseWithBye()
|
||||
client2, hello2 := NewTestClientWithHello(ctx, t, server2, hub2, testDefaultUserId+"2")
|
||||
defer client2.CloseWithBye()
|
||||
|
||||
session1 := hub1.GetSessionByPublicId(hello1.Hello.SessionId)
|
||||
require.NotNil(session1, "Session %s does not exist", hello1.Hello.SessionId)
|
||||
|
|
@ -863,6 +868,7 @@ func TestBackendServer_ParticipantsUpdateEmptyPermissions(t *testing.T) {
|
|||
defer cancel()
|
||||
|
||||
client, hello := NewTestClientWithHello(ctx, t, server, hub, testDefaultUserId)
|
||||
defer client.CloseWithBye()
|
||||
|
||||
session := hub.GetSessionByPublicId(hello.Hello.SessionId)
|
||||
assert.NotNil(session, "Session %s does not exist", hello.Hello.SessionId)
|
||||
|
|
@ -927,7 +933,9 @@ func TestBackendServer_ParticipantsUpdateTimeout(t *testing.T) {
|
|||
defer cancel()
|
||||
|
||||
client1, hello1 := NewTestClientWithHello(ctx, t, server, hub, testDefaultUserId+"1")
|
||||
defer client1.CloseWithBye()
|
||||
client2, hello2 := NewTestClientWithHello(ctx, t, server, hub, testDefaultUserId+"2")
|
||||
defer client2.CloseWithBye()
|
||||
|
||||
// Join room by id.
|
||||
roomId := "test-room"
|
||||
|
|
@ -1100,7 +1108,9 @@ func TestBackendServer_InCallAll(t *testing.T) {
|
|||
defer cancel()
|
||||
|
||||
client1, hello1 := NewTestClientWithHello(ctx, t, server1, hub1, testDefaultUserId+"1")
|
||||
defer client1.CloseWithBye()
|
||||
client2, hello2 := NewTestClientWithHello(ctx, t, server2, hub2, testDefaultUserId+"2")
|
||||
defer client2.CloseWithBye()
|
||||
|
||||
session1 := hub1.GetSessionByPublicId(hello1.Hello.SessionId)
|
||||
require.NotNil(session1, "Could not find session %s", hello1.Hello.SessionId)
|
||||
|
|
@ -1258,6 +1268,7 @@ func TestBackendServer_RoomMessage(t *testing.T) {
|
|||
defer cancel()
|
||||
|
||||
client, _ := NewTestClientWithHello(ctx, t, server, hub, testDefaultUserId+"1")
|
||||
defer client.CloseWithBye()
|
||||
|
||||
// Join room by id.
|
||||
roomId := "test-room"
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ func TestBandwidth_Client(t *testing.T) {
|
|||
hub.SetMcu(mcu)
|
||||
|
||||
client, hello := NewTestClientWithHello(ctx, t, server, hub, testDefaultUserId)
|
||||
defer client.CloseWithBye()
|
||||
|
||||
// Join room by id.
|
||||
roomId := "test-room"
|
||||
|
|
@ -476,6 +477,7 @@ func TestPermissionHideDisplayNames(t *testing.T) {
|
|||
defer cancel()
|
||||
|
||||
client, hello := NewTestClientWithHello(ctx, t, server, hub, testDefaultUserId)
|
||||
defer client.CloseWithBye()
|
||||
|
||||
roomId := "test-room"
|
||||
roomMsg := MustSucceed2(t, client.JoinRoom, ctx, roomId)
|
||||
|
|
@ -541,6 +543,7 @@ func TestPermissionHideDisplayNames(t *testing.T) {
|
|||
}
|
||||
|
||||
client2, hello2 := NewTestClientWithHello(ctx, t, server, hub, testDefaultUserId+"2")
|
||||
defer client2.CloseWithBye()
|
||||
|
||||
roomMsg2 := MustSucceed2(t, client2.JoinRoom, ctx, roomId)
|
||||
require.Equal(roomId, roomMsg2.Room.RoomId)
|
||||
|
|
|
|||
|
|
@ -5086,7 +5086,9 @@ func DoTestSwitchToMultiple(t *testing.T, details1 api.StringMap, details2 api.S
|
|||
defer cancel()
|
||||
|
||||
client1, hello1 := NewTestClientWithHello(ctx, t, server1, hub1, testDefaultUserId+"1")
|
||||
defer client1.CloseWithBye()
|
||||
client2, hello2 := NewTestClientWithHello(ctx, t, server2, hub2, testDefaultUserId+"2")
|
||||
defer client2.CloseWithBye()
|
||||
|
||||
roomSessionId1 := RoomSessionId("roomsession1")
|
||||
roomId1 := "test-room"
|
||||
|
|
|
|||
|
|
@ -221,7 +221,10 @@ func NewTestClientContext(ctx context.Context, t *testing.T, server *httptest.Se
|
|||
messageChan := make(chan []byte)
|
||||
readErrorChan := make(chan error, 1)
|
||||
|
||||
closing := make(chan struct{})
|
||||
closed := make(chan struct{})
|
||||
go func() {
|
||||
defer close(closed)
|
||||
for {
|
||||
messageType, data, err := conn.ReadMessage()
|
||||
if err != nil {
|
||||
|
|
@ -231,9 +234,17 @@ func NewTestClientContext(ctx context.Context, t *testing.T, server *httptest.Se
|
|||
return
|
||||
}
|
||||
|
||||
messageChan <- data
|
||||
select {
|
||||
case messageChan <- data:
|
||||
case <-closing:
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
t.Cleanup(func() {
|
||||
close(closing)
|
||||
<-closed
|
||||
})
|
||||
|
||||
return &TestClient{
|
||||
t: t,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue