MCPcopy
hub / github.com/livekit/livekit / TestRoomUpdate

Function TestRoomUpdate

pkg/rtc/room_test.go:775–807  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

773}
774
775func TestRoomUpdate(t *testing.T) {
776 t.Run("updates are sent when participant joined", func(t *testing.T) {
777 rm := newRoomWithParticipants(t, testRoomOpts{num: 1})
778 defer rm.Close(types.ParticipantCloseReasonNone)
779
780 p1 := rm.GetParticipants()[0].(*typesfakes.FakeLocalParticipant)
781 require.Equal(t, 0, p1.SendRoomUpdateCallCount())
782
783 p2 := NewMockParticipant("p2", types.CurrentProtocol, false, false, rm.LocalParticipantListener())
784 require.NoError(t, rm.Join(p2, nil, nil, iceServersForRoom))
785
786 // p1 should have received an update
787 time.Sleep(2 * defaultDelay)
788 require.LessOrEqual(t, 1, p1.SendRoomUpdateCallCount())
789 require.EqualValues(t, 2, p1.SendRoomUpdateArgsForCall(p1.SendRoomUpdateCallCount()-1).NumParticipants)
790 })
791
792 t.Run("participants should receive metadata update", func(t *testing.T) {
793 rm := newRoomWithParticipants(t, testRoomOpts{num: 2})
794 defer rm.Close(types.ParticipantCloseReasonNone)
795
796 rm.SetMetadata("test metadata...")
797
798 // callbacks are updated from goroutine
799 time.Sleep(2 * defaultDelay)
800
801 for _, op := range rm.GetParticipants() {
802 fp := op.(*typesfakes.FakeLocalParticipant)
803 // room updates are now sent for both participant joining and room metadata
804 require.GreaterOrEqual(t, fp.SendRoomUpdateCallCount(), 1)
805 }
806 })
807}
808
809type testRoomOpts struct {
810 num int

Callers

nothing calls this directly

Calls 10

newRoomWithParticipantsFunction · 0.85
NewMockParticipantFunction · 0.85
GetParticipantsMethod · 0.80
JoinMethod · 0.80
CloseMethod · 0.65
SetMetadataMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected