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)
|
require.NoError(t, err)
|
||||||
defer t2.Stop()
|
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 {
|
success := testutils.WithTimeout(t, "c2 should receive two tracks", func() bool {
|
||||||
if len(c2.SubscribedTracks()) == 0 {
|
if len(c2.SubscribedTracks()) == 0 {
|
||||||
return false
|
return false
|
||||||
@@ -78,9 +75,12 @@ func TestSinglePublisher(t *testing.T) {
|
|||||||
t.FailNow()
|
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
|
// ensure that new client that has joined also received tracks
|
||||||
waitUntilConnected(t, c3)
|
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 {
|
if len(c3.SubscribedTracks()) == 0 {
|
||||||
return false
|
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() {
|
if testing.Short() {
|
||||||
t.SkipNow()
|
t.SkipNow()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, finish := setupSingleNodeTest("TestAutoSubDisabled", testRoom)
|
_, finish := setupSingleNodeTest("Test_WhenAutoSubscriptionDisabled_ClientShouldNotReceiveAnyPublishedTracks", testRoom)
|
||||||
defer finish()
|
defer finish()
|
||||||
|
|
||||||
opts := testclient.Options{AutoSubscribe: false}
|
opts := testclient.Options{AutoSubscribe: false}
|
||||||
c1 := createRTCClient("c1", defaultServerPort, &opts)
|
publisher := createRTCClient("publisher", defaultServerPort, &opts)
|
||||||
c2 := createRTCClient("c2", defaultServerPort, &opts)
|
client := createRTCClient("client", defaultServerPort, &opts)
|
||||||
defer c1.Stop()
|
defer publisher.Stop()
|
||||||
defer c2.Stop()
|
defer client.Stop()
|
||||||
waitUntilConnected(t, c1, c2)
|
waitUntilConnected(t, publisher, client)
|
||||||
|
|
||||||
// c2 should not receive any tracks c1 publishes
|
track, err := publisher.AddStaticTrack("audio/opus", "audio", "webcam")
|
||||||
t1, err := c1.AddStaticTrack("audio/opus", "audio", "webcam")
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer t1.Stop()
|
defer track.Stop()
|
||||||
|
|
||||||
time.Sleep(syncDelay)
|
time.Sleep(syncDelay)
|
||||||
|
|
||||||
require.Empty(t, c2.SubscribedTracks()[c1.ID()])
|
require.Empty(t, client.SubscribedTracks()[publisher.ID()])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user