set joinedAt when participant is created

This commit is contained in:
David Zhao
2021-04-21 21:52:31 -07:00
parent 07e4ab0c2a
commit d6c155e060
2 changed files with 11 additions and 14 deletions
+7 -8
View File
@@ -49,14 +49,6 @@ func TestIsReady(t *testing.T) {
}
func TestICEStateChange(t *testing.T) {
t.Run("sets connectedAt when connected", func(t *testing.T) {
p := newParticipantForTest("test")
require.True(t, p.ConnectedAt().IsZero())
p.handlePublisherICEStateChange(webrtc.ICEConnectionStateConnected)
require.True(t, time.Now().Sub(p.ConnectedAt()) < time.Second)
})
t.Run("onClose gets called when ICE disconnected", func(t *testing.T) {
p := newParticipantForTest("test")
closeChan := make(chan bool, 1)
@@ -145,6 +137,13 @@ func TestDisconnectTiming(t *testing.T) {
})
}
func TestCorrectJoinedAt(t *testing.T) {
p := newParticipantForTest("test")
info := p.ToProto()
require.NotZero(t, info.JoinedAt)
require.True(t, time.Now().Unix()-info.JoinedAt <= 1)
}
func newParticipantForTest(identity string) *ParticipantImpl {
conf, _ := config.NewConfig("")
rtcConf, _ := NewWebRTCConfig(&conf.RTC, "")