use IsReady instead of checking for multiple statuses

This commit is contained in:
David Zhao
2021-01-10 22:09:36 -08:00
parent 7dcb88343a
commit 456df0fb91
7 changed files with 130 additions and 22 deletions
+42
View File
@@ -0,0 +1,42 @@
package rtc
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/livekit/livekit-server/proto/livekit"
)
func TestIsReady(t *testing.T) {
tests := []struct {
state livekit.ParticipantInfo_State
ready bool
}{
{
state: livekit.ParticipantInfo_JOINING,
ready: false,
},
{
state: livekit.ParticipantInfo_JOINED,
ready: true,
},
{
state: livekit.ParticipantInfo_ACTIVE,
ready: true,
},
{
state: livekit.ParticipantInfo_DISCONNECTED,
ready: false,
},
}
for _, test := range tests {
t.Run(test.state.String(), func(t *testing.T) {
p := &ParticipantImpl{
state: test.state,
}
assert.Equal(t, test.ready, p.IsReady())
})
}
}