Refactor singlenode_test.go (#131)
* Fix typo * test: move client creation to where it is used * Refactor TestAutoSubDisabled
This commit is contained in:
+14
-15
@@ -57,9 +57,6 @@ func TestSinglePublisher(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer t2.Stop()
|
||||
|
||||
// a new client joins and should get the initial stream
|
||||
c3 := createRTCClient("c3", defaultServerPort, nil)
|
||||
|
||||
success := testutils.WithTimeout(t, "c2 should receive two tracks", func() bool {
|
||||
if len(c2.SubscribedTracks()) == 0 {
|
||||
return false
|
||||
@@ -78,9 +75,12 @@ func TestSinglePublisher(t *testing.T) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
// a new client joins and should get the initial stream
|
||||
c3 := createRTCClient("c3", defaultServerPort, nil)
|
||||
|
||||
// ensure that new client that has joined also received tracks
|
||||
waitUntilConnected(t, c3)
|
||||
success = testutils.WithTimeout(t, "c2 should receive two tracks", func() bool {
|
||||
success = testutils.WithTimeout(t, "c3 should receive two tracks", func() bool {
|
||||
if len(c3.SubscribedTracks()) == 0 {
|
||||
return false
|
||||
}
|
||||
@@ -119,28 +119,27 @@ func TestSinglePublisher(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestAutoSubDisabled(t *testing.T) {
|
||||
func Test_WhenAutoSubscriptionDisabled_ClientShouldNotReceiveAnyPublishedTracks(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.SkipNow()
|
||||
return
|
||||
}
|
||||
|
||||
_, finish := setupSingleNodeTest("TestAutoSubDisabled", testRoom)
|
||||
_, finish := setupSingleNodeTest("Test_WhenAutoSubscriptionDisabled_ClientShouldNotReceiveAnyPublishedTracks", testRoom)
|
||||
defer finish()
|
||||
|
||||
opts := testclient.Options{AutoSubscribe: false}
|
||||
c1 := createRTCClient("c1", defaultServerPort, &opts)
|
||||
c2 := createRTCClient("c2", defaultServerPort, &opts)
|
||||
defer c1.Stop()
|
||||
defer c2.Stop()
|
||||
waitUntilConnected(t, c1, c2)
|
||||
publisher := createRTCClient("publisher", defaultServerPort, &opts)
|
||||
client := createRTCClient("client", defaultServerPort, &opts)
|
||||
defer publisher.Stop()
|
||||
defer client.Stop()
|
||||
waitUntilConnected(t, publisher, client)
|
||||
|
||||
// c2 should not receive any tracks c1 publishes
|
||||
t1, err := c1.AddStaticTrack("audio/opus", "audio", "webcam")
|
||||
track, err := publisher.AddStaticTrack("audio/opus", "audio", "webcam")
|
||||
require.NoError(t, err)
|
||||
defer t1.Stop()
|
||||
defer track.Stop()
|
||||
|
||||
time.Sleep(syncDelay)
|
||||
|
||||
require.Empty(t, c2.SubscribedTracks()[c1.ID()])
|
||||
require.Empty(t, client.SubscribedTracks()[publisher.ID()])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user