updated tests for participant update

This commit is contained in:
David Zhao
2021-03-16 22:31:09 -07:00
parent f7ed2cee60
commit 0de53f9a33
3 changed files with 85 additions and 1 deletions
+28
View File
@@ -1,6 +1,7 @@
package rtc_test
import (
"github.com/livekit/livekit-server/pkg/rtc/types"
"github.com/livekit/livekit-server/pkg/rtc/types/typesfakes"
livekit "github.com/livekit/livekit-server/proto"
"github.com/livekit/protocol/utils"
@@ -12,6 +13,33 @@ func newMockParticipant(identity string) *typesfakes.FakeParticipant {
p.IdentityReturns(identity)
p.StateReturns(livekit.ParticipantInfo_JOINED)
p.SetMetadataStub = func(m map[string]interface{}) error {
var f func(participant types.Participant)
if p.OnMetadataUpdateCallCount() > 0 {
f = p.OnMetadataUpdateArgsForCall(p.OnMetadataUpdateCallCount() - 1)
}
if f != nil {
f(p)
}
return nil
}
updateTrack := func() {
var f func(participant types.Participant, track types.PublishedTrack)
if p.OnTrackUpdatedCallCount() > 0 {
f = p.OnTrackUpdatedArgsForCall(p.OnTrackUpdatedCallCount() - 1)
}
if f != nil {
f(p, nil)
}
}
p.SetTrackMutedStub = func(sid string, muted bool) {
updateTrack()
}
p.AddTrackStub = func(s string, s2 string, trackType livekit.TrackType) {
updateTrack()
}
return p
}