mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Touched up snowflake client tests
There were a few tests that needed refreshing since the introduction of the pion library. Also added a few tests for the ICE server parsing function in the client.
This commit is contained in:
parent
dabdd847ce
commit
0f99c5ab12
3 changed files with 90 additions and 8 deletions
59
client/client_test.go
Normal file
59
client/client_test.go
Normal file
|
@ -0,0 +1,59 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
func TestICEServerParser(t *testing.T) {
|
||||
Convey("Test parsing of ICE servers", t, func() {
|
||||
for _, test := range []struct {
|
||||
input string
|
||||
urls [][]string
|
||||
length int
|
||||
}{
|
||||
{
|
||||
"",
|
||||
nil,
|
||||
0,
|
||||
},
|
||||
{
|
||||
" ",
|
||||
nil,
|
||||
0,
|
||||
},
|
||||
{
|
||||
"stun:stun.l.google.com:19302",
|
||||
[][]string{[]string{"stun:stun.l.google.com:19302"}},
|
||||
1,
|
||||
},
|
||||
{
|
||||
"stun:stun.l.google.com:19302,stun.ekiga.net",
|
||||
[][]string{[]string{"stun:stun.l.google.com:19302"}, []string{"stun.ekiga.net"}},
|
||||
2,
|
||||
},
|
||||
{
|
||||
"stun:stun.l.google.com:19302, stun.ekiga.net",
|
||||
[][]string{[]string{"stun:stun.l.google.com:19302"}, []string{"stun.ekiga.net"}},
|
||||
2,
|
||||
},
|
||||
} {
|
||||
servers := parseIceServers(test.input)
|
||||
|
||||
if test.urls == nil {
|
||||
So(servers, ShouldBeNil)
|
||||
} else {
|
||||
So(servers, ShouldNotBeNil)
|
||||
}
|
||||
|
||||
So(len(servers), ShouldEqual, test.length)
|
||||
|
||||
for i, server := range servers {
|
||||
So(server.URLs, ShouldResemble, test.urls[i])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue