Files
webrtc/rtcpeerconnection_close_test.go
Max Hawkins 0e7086d37a Remove RTC prefix from all names
Let's pull off the bandaid!

* Reduces studdering: webrtc.RTCTrack -> webrtc.Track
* Makes it easier to find types by editor autocomplete
* Makes code read more fluently (less repetition)

Since we're breaking the API in 2.0, our only chance to
do this is now.

Relates to #408
2019-02-17 16:22:56 -08:00

55 lines
923 B
Go

package webrtc
import (
"testing"
"time"
"github.com/pions/transport/test"
)
// TestPeerConnection_Close is moved to it's on file because the tests
// in rtcpeerconnection_test.go are leaky, making the goroutine report useless.
func TestPeerConnection_Close(t *testing.T) {
api := NewAPI()
// Limit runtime in case of deadlocks
lim := test.TimeOut(time.Second * 20)
defer lim.Stop()
report := test.CheckRoutines(t)
defer report()
pcOffer, pcAnswer, err := api.newPair()
if err != nil {
t.Fatal(err)
}
awaitSetup := make(chan struct{})
pcAnswer.OnDataChannel(func(d *DataChannel) {
close(awaitSetup)
})
_, err = pcOffer.CreateDataChannel("data", nil)
if err != nil {
t.Fatal(err)
}
err = signalPair(pcOffer, pcAnswer)
if err != nil {
t.Fatal(err)
}
<-awaitSetup
err = pcOffer.Close()
if err != nil {
t.Fatal(err)
}
err = pcAnswer.Close()
if err != nil {
t.Fatal(err)
}
}