Skip to content

Commit

Permalink
Extract TestPairSearch from agent_test.go
Browse files Browse the repository at this point in the history
to separate file.
  • Loading branch information
ashellunts committed Feb 7, 2023
1 parent 4dea724 commit 0d1c333
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 27 deletions.
39 changes: 39 additions & 0 deletions agent_pair_search_test.go
Original file line number Diff line number Diff line change
@@ -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 changes: 0 additions & 27 deletions agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 0d1c333

Please sign in to comment.