Extract TestPairSearch from agent_test.go

to separate file.
This commit is contained in:
Artur Shellunts
2023-02-07 13:01:42 +01:00
committed by Arthur Shellunts
parent 4dea7246b6
commit 0d1c333fcd
2 changed files with 39 additions and 27 deletions
+39
View File
@@ -0,0 +1,39 @@
//go:build !js
// +build !js
package ice
import (
"testing"
"time"
"github.com/pion/transport/test"
"github.com/stretchr/testify/assert"
)
func TestPairSearch(t *testing.T) {
report := test.CheckRoutines(t)
defer report()
// Limit runtime in case of deadlocks
lim := test.TimeOut(time.Second * 10)
defer lim.Stop()
var config AgentConfig
a, err := NewAgent(&config)
if err != nil {
t.Fatalf("Error constructing ice.Agent")
}
if len(a.checklist) != 0 {
t.Fatalf("TestPairSearch is only a valid test if a.validPairs is empty on construction")
}
cp := a.getBestAvailableCandidatePair()
if cp != nil {
t.Fatalf("No Candidate pairs should exist")
}
assert.NoError(t, a.Close())
}
-27
View File
@@ -31,33 +31,6 @@ func (m *mockPacketConn) SetDeadline(t time.Time) error {
func (m *mockPacketConn) SetReadDeadline(t time.Time) error { return nil }
func (m *mockPacketConn) SetWriteDeadline(t time.Time) error { return nil }
func TestPairSearch(t *testing.T) {
report := test.CheckRoutines(t)
defer report()
// Limit runtime in case of deadlocks
lim := test.TimeOut(time.Second * 10)
defer lim.Stop()
var config AgentConfig
a, err := NewAgent(&config)
if err != nil {
t.Fatalf("Error constructing ice.Agent")
}
if len(a.checklist) != 0 {
t.Fatalf("TestPairSearch is only a valid test if a.validPairs is empty on construction")
}
cp := a.getBestAvailableCandidatePair()
if cp != nil {
t.Fatalf("No Candidate pairs should exist")
}
assert.NoError(t, a.Close())
}
func TestPairPriority(t *testing.T) {
report := test.CheckRoutines(t)
defer report()