Simplify "WaitForUsersJoined" in tests.

This commit is contained in:
Joachim Bauch 2023-06-12 10:03:28 +02:00
parent b45f4a2bfc
commit c4ae9cdc6c
No known key found for this signature in database
GPG key ID: 77C1D22D53E15F02

View file

@ -2401,51 +2401,12 @@ func TestClientMessageToUserIdMultipleSessions(t *testing.T) {
func WaitForUsersJoined(ctx context.Context, t *testing.T, client1 *TestClient, hello1 *ServerMessage, client2 *TestClient, hello2 *ServerMessage) {
// We will receive "joined" events for all clients. The ordering is not
// defined as messages are processed and sent by asynchronous event handlers.
msg1_1, err := client1.RunUntilMessage(ctx)
if err != nil {
if err := client1.RunUntilJoined(ctx, hello1.Hello, hello2.Hello); err != nil {
t.Error(err)
}
msg1_2, err := client1.RunUntilMessage(ctx)
if err != nil {
if err := client2.RunUntilJoined(ctx, hello1.Hello, hello2.Hello); err != nil {
t.Error(err)
}
msg2_1, err := client2.RunUntilMessage(ctx)
if err != nil {
t.Error(err)
}
msg2_2, err := client2.RunUntilMessage(ctx)
if err != nil {
t.Error(err)
}
if err := client1.checkMessageJoined(msg1_1, hello1.Hello); err != nil {
// Ordering is "joined" from client 2, then from client 1
if err := client1.checkMessageJoined(msg1_1, hello2.Hello); err != nil {
t.Error(err)
}
if err := client1.checkMessageJoined(msg1_2, hello1.Hello); err != nil {
t.Error(err)
}
} else {
// Ordering is "joined" from client 1, then from client 2
if err := client1.checkMessageJoined(msg1_2, hello2.Hello); err != nil {
t.Error(err)
}
}
if err := client2.checkMessageJoined(msg2_1, hello1.Hello); err != nil {
// Ordering is "joined" from client 2, then from client 1
if err := client2.checkMessageJoined(msg2_1, hello2.Hello); err != nil {
t.Error(err)
}
if err := client2.checkMessageJoined(msg2_2, hello1.Hello); err != nil {
t.Error(err)
}
} else {
// Ordering is "joined" from client 1, then from client 2
if err := client2.checkMessageJoined(msg2_2, hello2.Hello); err != nil {
t.Error(err)
}
}
}
func TestClientMessageToRoom(t *testing.T) {