From 69c438ab30b0c7ce9fc3fba52458d42a51f663a5 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Fri, 26 Feb 2021 13:23:54 +0100 Subject: [PATCH] Add unit tests for ICEConfiguration and RelayTest. --- ice/ice_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/ice/ice_test.go b/ice/ice_test.go index 71197af..4b2efae 100644 --- a/ice/ice_test.go +++ b/ice/ice_test.go @@ -5,11 +5,15 @@ import ( "crypto/hmac" "crypto/sha1" "encoding/base64" + "os" "reflect" "strings" "testing" + "time" "github.com/pion/webrtc/v3" + + "github.com/jech/galene/turnserver" ) func TestPassword(t *testing.T) { @@ -63,3 +67,31 @@ func TestHMAC(t *testing.T) { t.Errorf("Got %v, expected %v", sss, ss) } } + +func TestICEConfiguration(t *testing.T) { + ICEFilename = "/tmp/no/such/file" + turnserver.Address = "" + + conf := ICEConfiguration() + if conf == nil { + t.Errorf("conf is nil") + } + conf2 := ICEConfiguration() + if conf2 != conf { + t.Errorf("conf2 != conf") + } + + if len(conf.ICEServers) != 0 { + t.Errorf("len(ICEServers) = %v", len(conf.ICEServers)) + } +} + +func TestRelayTest(t *testing.T) { + ICEFilename = "/tmp/no/such/file" + turnserver.Address = "" + + _, err := RelayTest(200 * time.Millisecond) + if err == nil || !os.IsTimeout(err) { + t.Errorf("Relay test returned %v", err) + } +}