mirror of
https://github.com/netbirdio/ice.git
synced 2026-05-22 17:10:58 -07:00
Rename TestPairSearch and refactor it
1. Extract test setup code so that it is visible what exactly is tested.
2. Removed check of checklist because that is tested by call to
getBestAvailableCandidatePair.
3. Use require.* instead of assert.*
4. Removed check for leaked routines and timer. Because the test is
super simple.
This commit is contained in:
committed by
Arthur Shellunts
parent
0d1c333fcd
commit
c8cff3a97a
@@ -0,0 +1,28 @@
|
||||
//go:build !js
|
||||
// +build !js
|
||||
|
||||
package ice
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestNoBestAvailableCandidatePairAfterAgentConstruction(t *testing.T) {
|
||||
agent := setupTest(t)
|
||||
|
||||
require.Nil(t, agent.getBestAvailableCandidatePair())
|
||||
|
||||
tearDownTest(t, agent)
|
||||
}
|
||||
|
||||
func setupTest(t *testing.T) *Agent {
|
||||
agent, err := NewAgent(&AgentConfig{})
|
||||
require.NoError(t, err)
|
||||
return agent
|
||||
}
|
||||
|
||||
func tearDownTest(t *testing.T, agent *Agent) {
|
||||
require.NoError(t, agent.Close())
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
//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())
|
||||
}
|
||||
Reference in New Issue
Block a user